0

I have an api which returns Binary Media Data (The data contains an image), I want to send this data to a file. I am able to do this via CURL command using -o. But I am not able to do the same in node js. Please help.

2
  • You may like to use npmjs.com/package/request module Commented May 10, 2018 at 7:15
  • using pipe method? By "send" here I mean storing data in a file. Commented May 10, 2018 at 7:18

1 Answer 1

3

You may use request module something like following

const fs = require('fs');
const request = require('request');

request
  .get('http://example.com/image.png')
  .pipe(fs.createWriteStream('image.png'))
Sign up to request clarification or add additional context in comments.

1 Comment

Great, If any answer works, You should accept that answer this will help to other as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.