Reputation: 611
I am trying make a GET request in SparkAR studio. I am able to import the https
module. However when the code runs I get the following error.
Possible Unhandled Promise Rejection: TypeError: Cannot read property 'protocol' of undefined
I found a reference to the networking module in this SO thread but the module is no longer supported. I get the following error.
Some modules are not supported by the platforms selected for this project: Networking is not supported by Instagram, Facebook. You can review the platforms by selecting Project > Edit Properties...
My code is below. I am don't work with node.js usually hence there might be some obvious mistake which I might be doing.
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);
});
})();
Upvotes: 0
Views: 618