getOnenetData:function() {
var that = this
let deviceid = "deviceid "
let apikey = "apikey "
wx.request({
url: "https://api.heclouds.com/devices/" + deviceid + "/datastreams",
method: 'GET',
data: {
picindex:''
},
header: {
"content-type": 'application/x-www-form-urlencoded',
// "content-type": 'application/octet-stream',
"api-key": apikey
},
success(res) {
if (res.statusCode === 200) {
/* console.log(res)*/
console.log(res)
that.setData({
picindex: res.data.data[0].current_value.index,
})
app.globalData.picindex = res.data.data[0].current_value.index
console.log(that.data.picindex)
console.log(app.globalData.picindex)
}
},
})
},
getOnenetpic: function () {
var that = this;
let apikey = 'maskapikey='//maskapi
wx.request({
url: "https://api.heclouds.com/bindata/" + app.globalData.picindex,
method:"GET",
responseType: 'arraybuffer',
data: {
img: '',
},
header:{
'api-key': apikey
},
success(res) {
if (res.statusCode === 200) {
console.log(res)
// console.log(that.data.picindex)
const base64=wx.arrayBufferToBase64(res.data)
console.log(base64)
that.setData({
img:"data:image/jpg;base64,"+base64
})
console.log(that.data.img)
}
}
})
},
请问新版本的onenet如何用微信小程序获取数据
从哪知道api没问题呢?postman调用下截个图