Skip to content

Blogposts

Fetch all blogposts

fetch('https://dummyapi.online/api/blogposts')
.then((response) => response.json())
.then((json) => console.log(json));
Output
[
{
"id": 1,
"title": "How to Build a Successful Blog",
"author": "John Doe",
"date_published": "2022-01-19",
"content": "Building a successful blog takes time, effort, and dedication..."
},
{
"id": 2,
"title": "The Importance of Self-Care for Bloggers",
"author": "Jane Smith",
"date_published": "2022-01-12",
"content": "Blogging, while rewarding, can also be stressful and demanding..."
},
...
]

Fetch a single blogpost

Getting a single entry of a certain resource. In this example, we use the /api/blogposts/1 route.

fetch('https://dummyapi.online/api/blogposts/1')
.then((response) => response.json())
.then((json) => console.log(json));
Output
{
"id": 1,
"title": "How to Build a Successful Blog",
"author": "John Doe",
"date_published": "2022-01-19",
"content": "Building a successful blog takes time, effort, and dedication..."
}

Show All Available Blogposts

To view all available blogposts, you can open the Blogposts Endpoint in your browser.