首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >小程序调用腾讯云人脸识别人员搜索按库返回接口显示is not a constructor怎么解决?

小程序调用腾讯云人脸识别人员搜索按库返回接口显示is not a constructor怎么解决?

提问于 2020-03-11 16:25:57
回答 0关注 0查看 239

其他的接口都可以用,人员搜索按库返回接口提示

代码语言:js
复制
{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"models.SearchPersonsReturnsByGroupRequest is not a constructor\nTypeError: models.SearchPersonsReturnsByGroupRequest is not a constructor\n    at synSearchPersonsReturnsByGroup (/var/user/index.js:18:13)\n    at EventHandler.exports.main [as realHandler] (/var/user/index.js:40:17)\n    at \u003canonymous\u003e\n    at process._tickCallback (internal/process/next_tick.js:188:7)"}
代码语言:js
复制
const cloud = require('wx-server-sdk') //小程序云开发SDK
const tencentcloud = require("tencentcloud-sdk-nodejs"); //腾讯云API 3.0 SDK
cloud.init() //云开发初始化
var synSearchPersonsReturnsByGroup = function (groupid, url) { //人脸识别API
 const IaiClient = tencentcloud.iai.v20180301.Client; //API版本
 const models = tencentcloud.iai.v20180301.Models; //API版本
 const Credential = tencentcloud.common.Credential;
 const ClientProfile = tencentcloud.common.ClientProfile;
 const HttpProfile = tencentcloud.common.HttpProfile;
 let cred = new Credential();  //这里填入你的SecretID和Secretkey,在腾讯云账号信息可以找到
 let httpProfile = new HttpProfile();
  httpProfile.endpoint = "iai.tencentcloudapi.com"; //腾讯云人脸识别API接口
 let clientProfile = new ClientProfile();
  clientProfile.httpProfile = httpProfile;
 let client = new IaiClient(cred, "", clientProfile); //调用就近地域
 let req = new models.SearchPersonsReturnsByGroupRequest();
 let params = '{"GroupIds.0":"' + groupid + '", "Url": "' + url + '", "SignatureMethod": "TC3-HMAC-SHA256"}' //拼接参数
  req.from_json_string(params);
 return new Promise(function (resolve, reject) { //构造异步函数.
    client.SearchPersonsReturnsByGroup(req, function (errMsg, response) {
 if (errMsg) {
        reject(errMsg)
      } else {
        resolve(response);
      }
    })
  })
}
exports.main = async (event, context) => {
 const data = event
 const fileList = [data.fileID] //读取来自客户端的fileID
 const result = await cloud.getTempFileURL({
    fileList, //向云存储发起读取文件临时地址请求
  })
 const url = result.fileList[0].tempFileURL
  datas = await synSearchPersonsReturnsByGroup(data.groupid, url) //调用异步函数,向腾讯云API发起请求
 return datas
}

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档