How does leancloud's cloud engine access Wechat's server?

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.

< hr >
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.
May.13,2021

the request of the cloud function is different from your request. The request of a cloud function refers to the internally encapsulated object.

your request here refers to the request module in nodejs.

get used to using axios,. Here we use axios to write an example.

npm install axios --save
AV.Cloud.define('getData', function(request) {
 axios.get('https://api.weixin.qq.com/cgi-bin/token', {
 params: { 
     'grant_type': 'client_credential',
     'appid': 'xxxxxxxxxxxxxxxxxxx',
     'secret': 'xxxxxxxxxxxxxxxxxx',    
   }
}).then(function (response) {
    // 
}).catch(function (error) {
// 
    alert(error);
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dea4-4f036.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dea4-4f036.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?