node Koa 对接 快递鸟
koa2-request,md5模块
router.get("/api/kd_select", async (ctx) => {
let requestData = "{'OrderCode':'','ShipperCode':'快递公司编码','LogisticCode':'你的物流号'}";
let cba = requestData + "你的key";
let abc = md5(cba);
let base = Buffer.from(abc).toString('base64');
let result = encodeURIComponent(base);
let body = encodeURIComponent(requestData);
let data = "";
let res = await koa2Req({
url: "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx?EBusinessID=你的商户ID&RequestType=1002&DataSign=" + result,
method: 'POST',
headers: {
"content-type": "application/x-www-form-urlencoded;charset=utf-8"
},
form: ({
RequestData: body
})
});
ctx.body = {
status: 200,
data: JSON.parse(res.body)
}
});
原创不易 转载带连接谢谢