700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > nodejs request模块post 请求使用 -- 实例 获取微信公众号素材列表

nodejs request模块post 请求使用 -- 实例 获取微信公众号素材列表

时间:2021-01-15 15:46:50

相关推荐

nodejs request模块post 请求使用 -- 实例 获取微信公众号素材列表

post请求有几种数据的发送方式,body\form…,根据接口需求传递

后台nodejs

向微信发起post 请求方式

// req.body 就是前台传过来的数据let url = `https://api./cgi-bin/material/batchget_material?access_token=${req.body.access_token}`;let data = {type: "image",offset: req.body.pageSize * (req.body.currenPage - 1),count: req.body.pageSize,};// post form表单形式request.post({url: url,form: JSON.stringify(data)}, function (error, response, body) {if (!error && response.statusCode == 200) {console.log(body) // 请求成功的处理逻辑 }})// post body形式// request({// url: url,// method: "POST",// json: true,// headers: {//"content-type": "application/json",// },// body: JSON.stringify(data)// }, function (error, response, body) {// console.log("response************************");// console.log(response);// console.log("response************************");// if (!error && response.statusCode == 200) {//console.log(body) // 请求成功的处理逻辑// }// next();// });

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。