I need to access Wechat server to get token to generate QR code. Mini Program is not allowed to keep the secret in the front end, so he needs a background to access Wechat"s server. I have little background knowledge. How to write the cloud function in order to access Wechat server? Please use the js method. Thank you.
Wechat"s address is like this.
https request method: GET
https://api.weixin.qq.com/cgi.
var request1 = require("request");
request1({
method: "GET",
url: "https://www.baidu.com",
json: {
title: "Vote for Pedro",
body: "If you vote for Pedro, your wildest dreams will come true"
}
}, function(err, res, body) {
if (err) {
console.error("Request failed with response code " + res.statusCode);
return"haha error";
} else {
console.log(body);
return "success";
}
});`
< hr >
I glued the above code into the cloud function, and the result is {} empty. It seems that request
is not recognized.