Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
How do I copy to clipboard using clipboardy?

I am trying to use clipboard in order to copy 'longlat' to the clipboard by passing it through the function 'copyData()'. However, it keeps giving me errors.

This is the error (1. Clipboardy.writeSync not a function and 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.

This is my code


  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();



about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

cy.window().its('navigator.clipboard')
    .invoke('readText').then((data) => {
                console.log(data);
            })

Should do the trick. If you are using cypress on the browser

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!