package.json
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "apicall.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"request": "^2.83.0"
}
}
steps
npm install
node apicall.js
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "apicall.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"request": "^2.83.0"
}
}
apicall.js
var fs = require("fs");
var request = require("request");
var fs = require('fs');
var request = require('request');
request.post({
url: 'https://url/upload',
formData: {
keyName1: 'value1',
keyName2: 'value2',
file: fs.createReadStream('d:/temp/30off.jpg')
},
}, function(error, response, body) {
console.log(body);
});
steps
npm install
node apicall.js
No comments:
Post a Comment