Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
Copy response.text() from fetch api in Chrome DevTools to the clipboard

I've tried using JS's copy() and creating an element/populating it with the data/copying the result. I cannot figure out how to get the response.text() to the clipboard.

The actual fetch is an XHR but the below example should suffice:

fetch('/readme.txt')
    .then(response => response.text())
    .then(data => console.log(data));
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to get response text and then copy it to the clipboard using another function:

fetch('/readme.txt').then(
    response => response.text()
).then(
    text => {
        navigator.clipboard.writeText(text).then(
            () => console.log("Success!"),
            (err) => console.log("Error copying response text", err)
        )
    }
)

In old browsers navigator.clipboard can be unavailable, you can get more info about copying in this answer

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda