const cloud = require( 'wx-server-sdk' );
var request = require( 'request' );
cloud.init()
exports.main = async (event, context) => {
var options = {
method: 'post' ,
preambleCRLF: true ,
postambleCRLF: true ,
uri: 'https://www.baidu.com' ,
multipart: [
{
body: 'I am nodejs request messages'
}
]
};
var result = {};
var isReturn = false ;
request(options, function (error, response, body) {
if (error) {
return console.error( 'upload failed:' , error);
}
result = body;
isReturn = true ;
console.log( "post done" );
});
var i = 0;
while (isReturn !== true ){
console.log( "whileing" );
i++;
}
console.log( "want to return" );
return result;
}
|
这是我在服务端写的一段测试代码,发现http请求根本发不出去,每次都超时。是不是云开发禁止发http请求的 如果是的话 要如何支付呢