Ciao, voglio accedere ai dati dell’utente (summary.json) situati su https://www.chiefdelphi.com/u/ereeen1208/summary.json utilizzando Nextjs typescript per un progetto. (chiefdelphi è un forum di discourse per FRC) Ho provato a utilizzare più metodi ma ogni metodo risulta in un errore o non ha successo:
(In tutti gli esempi, url = “https://www.chiefdelphi.com/u/ereeen1208/summary.json”)
Codice che restituisce una risposta vuota:
const response = await fetch(url, {
mode: "no-cors",
method: "GET"
})
Codice che restituisce errori CORS:
const response = await fetch(url, {
mode: "cors",
method: "GET"
})
const { data } = await axios.get(url);
Errore per fetch():
Access to fetch at ‘https://www.chiefdelphi.com/u/ereeen1208/summary.json’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
Errore per axios.get():
Access to XMLHttpRequest at ‘https://www.chiefdelphi.com/u/unpicasso/summary.json’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Cosa posso fare per ottenere i dati da questo URL? Avrei bisogno di provare un metodo di web scraping diverso o aggiungere più parametri? Grazie.