【发布时间】:2021-04-23 02:59:30
【问题描述】:
我正在尝试在 SparkAR 工作室中发出 GET 请求。我能够导入 https 模块。但是,当代码运行时,我收到以下错误。
可能的未处理承诺拒绝:TypeError:无法读取未定义的属性“协议”
我在SO thread 中找到了对网络模块的引用,但该模块不再受支持。我收到以下错误。
为此项目选择的平台不支持某些模块: Instagram、Facebook 不支持联网。 您可以通过选择 Project > Edit Properties... 来查看平台。
我的代码如下。我通常不使用 node.js,因此我可能会犯一些明显的错误。
const Scene = require('Scene');
export const Diagnostics = require('Diagnostics');
export const https = require('https');
(async function () { // Enables async/await in JS [part 1]
Diagnostics.log('Console message logged from the script.');
Diagnostics.log(https);
https.get('https://api.openweathermap.org/data/2.5/weather?appid={openweathermap_apikey}&q=chicago', (res) => {
Diagnostics.log('statusCode:', res.statusCode);
Diagnostics.log('headers:', res.headers);
res.on('data', (d) => {
Diagnostics.log('Data:', d);
});
}).on('error', (e) => {
Diagnostics.log('error:', e);
});
})();
【问题讨论】:
标签: javascript spark-ar-studio