Skip to content

Commit

Permalink
fix load json from streetmix.net
Browse files Browse the repository at this point in the history
  • Loading branch information
Algorush committed Sep 27, 2023
1 parent 0c281e5 commit 7e46136
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ AFRAME.registerComponent('streetmix-loader', {
var request = new XMLHttpRequest();
console.log('[streetmix-loader]', 'GET ' + data.streetmixAPIURL);

// for using inside request callback function
const loadFromJSON = this.loadFromJSON.bind(this);
request.open('GET', data.streetmixAPIURL, true);
request.onload = function () {
if (this.status >= 200 && this.status < 400) {
// Connection success
const streetmixResponseObject = JSON.parse(this.response);
this.loadFromJSON(streetmixResponseObject);
loadFromJSON(streetmixResponseObject);
} else {
// We reached our target server, but it returned an error
console.log('[streetmix-loader]', 'Loading Error: We reached the target server, but it returned an error');
Expand Down

0 comments on commit 7e46136

Please sign in to comment.