自建图像分类模型,开发一个看图识物的小程序,在发送比对请求时,为啥没有返回任何值?小程序开发工具里有一段错误提示(见截图),在百度提交工单回复可能是小程序调用函数不妥,请教高手指导。
//扫描图片中的数据
scanImageInfo: function (imageData) {
var that = this;
//红木模型
const detectUrl = `https://aip.baidubce.com/rpc/2.0/ai_custom/v1/classification/hongmu?access_token=${getApp().globalData.baiduToken}`;
//显示加载界面
wx.showLoading({
title: '加载中',
mask: true,
});
return new Promise(function (resolve, reject) {
wx.request({
url: detectUrl,
data: {
image: imageData
},
method: 'POST',
dataType: "json",
header: {
'content-type': 'application/x-www-form-base64'//红木模型
},
success: res => {
//隐藏加载界面
wx.hideLoading()
resolve(res);
},
fail: res => {
wx: wx.showToast({
title: '忙碌,稍后再试',
icon: 'none',
mask: true,
duration: 2000
})
reject(res);
},
})
})
},
百度工单回复
您的这个错误不是接口返回的,是小程序里面的错误。初步看您的代码应该是showLoading或者showToast这段代码使用方式不对,您查看小程序的文档对比一下呢。小程序的日志在开发的时候应该可以直接在控制台上看到,或者在调试器中能看到。