云函数调用https请求。代码正常,但是就是报错404011?
控制台的错误信息:
Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID , cloud function service error code -504002, error message Function not found [getPostDetail]; at cloud.callFunction api;
小程序里调用云函数的代码:
// 调用云函数 wx.cloud.callFunction({ name: 'getPostDetail', data: { id: this.id }, success: res => { }, fail: err => { } }) |
云函数 index.js代码
// 云函数入口文件const cloud = require('wx-server-sdk')var rp = require('request-promise');cloud.init()// 云函数入口函数exports.main = async (event, context) => { return await rp({ method: 'POST', uri: 'https://xxxxxxxx', body: { id: event.id, }, headers:{ 'cookie':'xxxxxx', 'Content-Type': 'application/json', }, json: true }).then(function (res) { return res }) .catch(function (err) { });} |
云函数请求url https://xxxxxxxx 已在config.json里添加
{ "permissions": { "openapi": [ "https://xxxxxxxxx" ] }} |
