扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

javascript如何https请求

扬州沐宇科技
2021-03-03 12:35:53
HTTPS, JavaScript

javascript如何https请求

在javascript中使用btoa()方法实现https请求,具体方法如下:

function b64EncodeUnicode(str) {

return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,

function(match, p1) {

return String.fromCharCode('0x' + p1);

}));

}

扫码添加客服微信