nodejs测试代码:
const Core = require('@alicloud/pop-core');
var client = new Core({
accessKeyId: 'LTAI5t6SEt9sbKh8arSW88PR',
accessKeySecret: 'HW2PB7pm5jOSfJX3IIaKfPnTejtUGE',
// securityToken: '<your-sts-token>', // use STS Token
endpoint: 'https://iot.cn-shanghai.aliyuncs.com',
apiVersion: '2018-01-20'
});
var params = {
"Items": "{\"temperature\":77777}",
"DeviceName": "mqttSimulator",
"ProductKey": "hl46zLyhuQC",
"IotInstanceId": "iot-06z00ezzxzvv6c8"
}
var requestOption = {
method: 'POST',
formatParams: false,
};
client.request('SetDeviceProperty', params, requestOption).then((result) => {
console.log(JSON.stringify(result));
}, (ex) => {
console.log(ex);
})
上面的代码在vscode和hbuilderX上的node项目中跑都不会有任何问题,但是在uniapp vue2项目,自建按钮跑是就爆出问题:
"message": "Cannot read property 'getHeaders' of undefined",
"stack": "TypeError: Cannot read property 'getHeaders' of undefined\n at http://localhost:8080/static/js/pages-index-index.js:32870:33\n at <anonymous>"
不知道问题出在哪了?
2 个回复
a***@yoshino.fun
同问,不知道问题在哪
JasonCaiM
各位大佬这个问题解决了吗?我也是跑在浏览器上没有问题,真机运行就报[Vue warn]: Error in mounted hook: "TypeError: WS is not a constructor"错误。大家能否一起讨论一下?bug_me_cjx@163.com