DEV Community

Discussion on: Welcome Thread - v155

Collapse
 
decocodes profile image
Deco

You can check the api docs here: developers.forem.com/api

Collapse
 
cleveroscar profile image
Oscar Ortiz • Edited

I am currently working on this still. Here is my code for example.

  axios.get("https://dev.to/api/articles/me/published", {
            headers: {
                'api-key': process.env.REACT_APP_DEV_API_KEY,
            },
        }).then(res => console.log(res)).catch(err => console.log(err));
Enter fullscreen mode Exit fullscreen mode

but I keep getting an error message saying I am not authorized.

Thread Thread
 
decocodes profile image
Deco

Your request seems fine.

I've tried it right now and got the same problem.

Maybe a problem with the api endpoint.

In a strange way making the request through curl worked for me.

Thread Thread
 
decocodes profile image
Deco

Found the problem.

It's CORS.

Actually CORS is disabled for public API requests but not for restricted endpoints.

Take a look in some workarounds:

dev.to/jrsofty/cors-problem-workar...

Thread Thread
 
cleveroscar profile image
Oscar Ortiz

I appreciate this! Thank you for being such great help