Estoy tratando de usar el portapapeles para copiar 'longlat' en el portapapeles pasándolo a través de la función 'copyData ()'. Sin embargo, me sigue dando errores.
Este es el error (1. Clipboardy.writeSync no es una función y 2. UnhandledPromiseRejectionWarning):
(node:16596) UnhandledPromiseRejectionWarning: TypeError: clipboardy.writeSync is not a function at copyData (C:\Users\Nicky\index.js:46:14) at C:\Users\Nicky\index.js:32:13 at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:16596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:16596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.este es mi codigo
const clipboardy = (...args) => import('clipboardy').then(({default: clipboardy}) => clipboardy(...args)); const puppeteer = require("puppeteer"); const url = "https://www.google.com/"; async function StartScraping() { await puppeteer .launch({ headless: false, }) .then(async (browser) => { const page = await browser.newPage(); await page.setViewport({ width: 2000, height: 800, }); page.on("response", async (response) => { if (response.url().includes("General")) { const location = await response.text() let intlong = location.indexOf("Example:") const longlat = location.substring(intlong, intlong + 46) console.log(longlat); copyData(longlat) } }); await page.goto(url, { waitUntil: "load", timeout: 0, }); }); } function copyData(data1) { clipboardy.writeSync(data1) } StartScraping();cy.window().its('navigator.clipboard') .invoke('readText').then((data) => { console.log(data); })Debería hacer el truco. Si está utilizando Cypress en el navegador