Reputation: 3140
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.
Upvotes: 0
Views: 674
Reputation: 5069
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'))
Upvotes: 3