'Fetching JSON data from self downloading url
I made some code that fetches data from url's in JSON format. However, I encountered today a url that when you go to it, it automatically starts a download. When I take this download and open it with a browser, I see JSON format data in my browser. So in order to read this data I have to modify my code to locally read that downloaded file. But I don't want to do that because I don't want to store the data on my computer. Is it possible to read this JSON data without actually downloading it ?
edit: @Amadan ... The downloading start if I paste the link in the browser and press enter. Of course if I fetch the link in NodeJS I get an error message. My fetch method works perfect for links to JSON pages that don't trigger a download when I paste the link in the browser.
I fetch with following code:
export async function retrieveData(url)
{
return await fetch(url)
.then(response => response.json())
.then((jsonData) => {
// jsonData is parsed json object received from url
return jsonData;
})
.catch((error) => {
throw error;
});}
The error message I got says: Uncaught (in promise) TypeError: Failed to Fetch
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|