如何使用云开发调用外部接口?

小程序 文章 2022-03-29 19:00 505 0 全屏看文

AI助手支持GPT4.0

如何使用云开发调用外部接口?How to use cloud development to call external interfaces?

如何使用云开发调用外部接口?

我想调用百度的垃圾识别的一个接口,该如何调用呢

I want to call an interface of Baidu's garbage identification. How can I call it

回答:

孙翰南:

调百度识别应该是上传图片,用upload的接口

拾忆:
var request = require("request"); function main(params) {   var options = {      url: "https://api.xxx.com",      json: true   };    return new Promise(function (resolve, reject) {      request(options, function (err, res) {         if (err) {            console.log(err);            return reject({err: err});         }      return resolve(res.body);      });   });}
深圳市春夏秋冬信息互联科技有限公司:

通过云函数请求第三方接口 比如 request、axios 等模块

-EOF-

AI助手支持GPT4.0