DEV Community

Discussion on: Embed dev.to posts into your own website

Collapse
 
psypher1 profile image
James 'Dante' Midzi

The specific endpoint, I see...

From my testing, I have found this:
This endpoint: https://dev.to/api/articles?username=psypher1 gets my articles but without the body_html

That for some reason is only on the specific paths when you know the path you're trying to get, which presents issues with the way Astro fetches things (needs to know all the paths).... I would need an endpoint that exposes all the post information

Thread Thread
 
psypher1 profile image
James 'Dante' Midzi

Also, looking deeper at your code, the key part is page.params.slug

I'll work on reverse engineering that for my getStaticPaths

Thread Thread
 
nunogois profile image
Nuno Góis

Hmm, if that's the case I guess you can always fetch everything at once (loop through the articles and fetch their respective information) - That way you would end up with the complete dataset at the start/build time.

You can also check the API docs - Maybe there's a solution for your specific use case where the article info is expanded.

Like I said I'm not familiar with Astro yet, but it feels like it should have a solution for this specific use-case. These resources might help:

Thread Thread
 
psypher1 profile image
James 'Dante' Midzi

Thank you for this...

It's not the dynamic pages that are the issue - that I can do...

The url I need is one with all posts with all the content... I'll have a dig around the docs

Thread Thread
 
psypher1 profile image
James 'Dante' Midzi

Hey @nunogois

I got it! The docs were the key... for Astro I have to use this one https://dev.to/api/articles/me/published with an API key

I can write my article now

Thread Thread
 
nunogois profile image
Nuno Góis

Great that you got it, thanks for sharing! 🙂

Thread Thread
 
psypher1 profile image
James 'Dante' Midzi

Thank you for the help