0
如何在Node.js中执行以下请求?这个curl请求在Node.js中看起来像什么?
curl "https://mysite.com/page " -F 'format=js' -F 'attachment[a]=1' -F'attachment[attachment][email protected]'
我使用restler试过,但我做错了。不知道是什么。
var restler = require('restler');
var fs = require('fs');
var email = '[email protected]',
password = 'mypass',
url = 'https://mysite.com/something';
fs.stat('test.txt', function(err, stats) {
restler.postJson(url, JSON.stringify({
format: 'js',
attachment: restler.file('test.txt', null, stats.size,
null, 'text/plain')
})).on('complete', function(data) {
console.log(data);
});
});
不知道为什么我没有想到这一点。谢谢! – davorb