Accessing user data from a Discourse Forum API

Hello, I want to access the user data (summary.json) located at https://www.chiefdelphi.com/u/ereeen1208/summary.json using Nextjs typescript for a project. (chiefdelphi is a discourse forum for FRC) I’ve tried using multiple methods but each method results in an error or is unsuccessfull:

(In all examples, url = “https://www.chiefdelphi.com/u/ereeen1208/summary.json”)

Code that returns empty response:

const response = await fetch(url, {
            mode: "no-cors",
            method: "GET"
        })

Code that returns cors errors:

const response = await fetch(url, {
            mode: "cors",
            method: "GET"
})
const { data } = await axios.get(url);

Error for 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.

Error for 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.

What can I do to get the data from this url? Would I need to try a different web scraping method or add more parameters? Thanks.

1 Like

hi @EReeeN1208 perhaps this might help?

1 Like