标签:上传 link save from class span ipa color content
导入
npm install request --save
get 请求
@Get(‘/xxxxx‘)
async getImage(@Req() request: Request, @Res() response: Response) {
const url = request.query.url;
requestHttp(url).pipe(response);
}
post 请求
requestHttp.post(url).form(request.body).pipe(response);
或者
requestHttp({
method : ‘post‘,
uri: url,
form: request.body
})
.pipe(response)
requestHttp({
method : ‘post‘,
uri: url,
json: true,
headers: {
"content-type": "application/json",
},
body: request.body,
})
.pipe(response);
var formData = {
// Pass a simple key-value pair
my_field: ‘my_value‘,
// Pass data via Buffers
my_buffer: new Buffer([1, 2, 3]),
// Pass data via Streams
my_file: fs.createReadStream(__dirname + ‘/unicycle.jpg‘),
};
request.post({url:url, formData: formData}, function (error, response, body) {
if (!error && response.statusCode == 200) {
}
})
标签:上传 link save from class span ipa color content
原文地址:https://www.cnblogs.com/jcz1206/p/13640039.html