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

391
Views
Obtener una imagen (Node.js)

Estoy tratando de obtener la imagen de https://api-assets.clashroyale.com/cards/300/CoZdp5PpsTH858l212lAMeJxVJ0zxv9V-f5xC8Bvj5g.png El código para obtener:

 fetch('https://api-assets.clashroyale.com/cards/300/CoZdp5PpsTH858l212lAMeJxVJ0zxv9V-f5xC8Bvj5g.png', ) .then(res => res.blob()) .then(myBlob => URL.createObjectURL(myBlob));

El error:

 node:internal/errors:464 ErrorCaptureStackTrace(err); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "obj" argument must be an instance of Blob. Received an instance of Blob at new NodeError (node:internal/errors:371:5) at Function.createObjectURL (node:internal/url:960:13) at C:\Users\lars\OneDrive - CVO-AV\Documenten\GuideBot\src\Commands\clash.js:45:37 at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 'ERR_INVALID_ARG_TYPE' }

versión del nodo: v16.13.1

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Descubrí que node-fetch aún no es compatible con .blob() , por lo que deberá hacerlo como el ejemplo en npm :

 const { pipeline } = require('node:stream'); const { promisify } = require('node:util'); const { createWriteStream } = require('node:fs'); const streamPipeline = promisify(pipeline) const response = await fetch('https://api-assets.clashroyale.com/cards/300/CoZdp5PpsTH858l212lAMeJxVJ0zxv9V-f5xC8Bvj5g.png'); await streamPipeline(response.body, createWriteStream('./octocat.png'))

Que devuelve la imagen correctamente: https://cdn.discordapp.com/attachments/950681875733708820/967324291161010216/unknown.png

about 4 years ago · Santiago Trujillo 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!