I'm trying to grab blob data from the url image provided by facebook. I'm new to network protocols and most of the questions seem to be out of date or in php. This is being done on a node server and the url is being passed in, it come in good and still works but the image won't load in. I've tried using XMLHttp to get the image in blob form but it gives back "network error".
const XMLHttpRequest = require('xhr2');
function loadXHR(url) {
return new Promise((resolve, reject) => {
try {
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.onerror = function() {reject("Network error.")};
xhr.onload = function() {
if (xhr.status === 200) {resolve(xhr.response)}
else {reject("Loading error:" + xhr.statusText)}
};
xhr.send();
}
catch(err) {reject(err.message)}
});
}
Not sure what the way to get the blob data is. I'm going to store the blob in the db after load to then serve it back to user later so just storing the urls doesn't work as they expire. I feel like I'm missing something simple but don't know where to find it.