个人小程序云函数能否打开https?
发布于 5 年前 作者 xxiong 13298 次浏览 来自 官方Issues

请问个人小程序云函数能否打开https普通链接(已有node_modules)?需要SSL之类的设置吗?

const cloud = require(‘wx-server-sdk’)

var rp = require(‘request-promise’);

cloud.init()

exports.main = async (event, context) => {

  let url = ‘https://www.baidu.com’;

  return await rp(url)

    .then(function (res) {

      return res

    })

    .catch(function (err) {

      return ‘失败’

    });

}

运行出错:

fail Error: cloud.callFunction:fail -404011 cloud function execution error. 云函数执行错误

云端堆栈信息(error stack)(requestId d4be8cb1-8c98-11eb-b043-525400fff70d, callid 1616587358758-0.45454444557093265):

Runtime.ImportModuleError: Error: Cannot find module ‘wx-server-sdk’

    at Object.module.exports.load (:24278/var/runtime/node10/UserFunction.js:35)

    at Runtime.handleOnce (:24278/var/runtime/node10/Runtime.engine.js:95)

    at Timeout.setTimeout [as _onTimeout] (:24278/var/runtime/node10/Runtime.engine.js:54)

    at ontimeout (:24278/appservice/timers.js:436)

    at tryOnTimeout (:24278/appservice/timers.js:300)

    at listOnTimeout (:24278/appservice/timers.js:263)

    at Timer.processTimers (:24278/appservice/timers.js:223)

2 回复

云函数请求https返回数据

小程序内打开https网站

你报的是这个错误,看看package配置了没

回到顶部