let file = new Blob([response.data], {type: 'application/json'});
response.data contains JSON file, I want to read the contents of this file and assign them as a JSON string to a variable in javascript.
I've tried a few things with FileReader.readAsText(file) but I'm not able to properly convert it into a simple JSON string.
P.S.: The response.data is an arraybuffer, so if there's a direct conversion that's possible without creating a Blob object, that should also solve the problem.
let file = new Blob([response.data], {type: 'application/json'});
file.text()
.then(value => {
self.objectName = JSON.parse(value);
console.log(self.objectName);
})
.catch(error => {
console.log("Something went wrong" + error);
});
Did the trick for me.