The API endpoint to retrieve blog posts data is:
https://devpromote.online/api/data
let headersList = { "Accept": "*/*", "User-Agent": "Thunder Client (https://www.thunderclient.com)" }; let response = await fetch("https://devpromote.online/api/data", { method: "GET", headers: headersList }); let data = await response.json(); console.log(data);
import React, { useEffect, useState } from 'react'; const BlogPosts = () => { const [data, setData] = useState([]); const [error, setError] = useState(null); useEffect(() => { const fetchData = async () => { try { const response = await fetch("https://devpromote.online/api/data"); if (!response.ok) { throw new Error("Network response was not ok"); } const result = await response.json(); setData(result); } catch (err) { console.error("Fetch error:", err); setError(err.message); } }; fetchData(); }, []); return ( <div> <h1>Blog Posts from API</h1> {error && <p style={{ color: "red" }}>Error: {error}</p>} <div> {data.map((item) => ( <div key={item.slug}> <a href={`https://devpromote.online/items/${items.slug}`} rel="noopener noreferrer"> <h2>{item.title}</h2> </a> <p>User ID: {item.userId}</p> <p>Tags: {item.tags ? item.tags.join(", ") : "No tags"}</p> </div> ))} </div> </div> ); }; export default BlogPosts;
Enter the API endpoint and click "Test API" to fetch data: