The problem is here you want to return from fetch browser API, which returns Promise. If you really want to do it, for instance, instead of using useState hook in React to call and save the response in component state, then you need to wrap your fetch request into async IIFE function and use await statement to wait the async request to be fulfilled and the data to be resolved by Promise. For more info, you can refer: JS Fetch API access return value

Answer from flosisa on Stack Overflow
🌐
JSONPlaceholder
jsonplaceholder.typicode.com
JSONPlaceholder - Free Fake REST API
fetch('https://jsonplaceholder.typicode.com/todos/1') .then(response => response.json()) .then(json => console.log(json)) Run script
Discussions

javascript - Returning a dummy json response - Stack Overflow
What I intended to do seemed simple at first sight but I've been unable to finish off. I have a javascript code that creates an array and uses JSON library to create my json response which is store... More on stackoverflow.com
🌐 stackoverflow.com
Anyone have a favorite free service that has dummy JSON that can be queried over HTTP?
https://www.reddit.com/.json More on reddit.com
🌐 r/javascript
19
48
January 28, 2017
Reliable API for dummy data?
You could always run a fake API locally like with json server More on reddit.com
🌐 r/reactjs
14
16
March 19, 2021
Create a dummy REST API from a json file with zero coding in seconds
Not to be a downer, but take a look at wiremock. More on reddit.com
🌐 r/golang
15
52
August 6, 2020
🌐
DummyJSON
dummyjson.com
DummyJSON - Free Fake REST API for Placeholder JSON Data
DummyJSON provides a free fake REST API with placeholder JSON data for development, testing, and prototyping. Access realistic data quickly for your projects.
🌐
DummyJSON
dummyjson.com › docs
Docs - DummyJSON - Free Fake REST API for Placeholder JSON Data
/* providing access token in bearer */ fetch('https://dummyjson.com/auth/RESOURCE', { method: 'GET', /* or POST/PUT/PATCH/DELETE */ headers: { 'Authorization': 'Bearer /* YOUR_ACCESS_TOKEN_HERE */', 'Content-Type': 'application/json' }, }) .then(res => res.json()) .then(console.log);
🌐
Eviltester
apichallenges.eviltester.com › practice-sites › dummyjson
Dummy JSON - A Mix of API Simulator and GET API - Practice API
In addition to our API Challenges you should practice on as many sites as possible. Try DummyJSON. Dummy JSON is a mix of an API Simulator with canned responses to requests, and also functional API endpoints that you can actually test.
🌐
GitHub
github.com › typicode › json-server
GitHub - typicode/json-server: Get a full fake REST API with zero coding in less than 30 seconds (seriously) · GitHub
4 weeks ago - Get a full fake REST API with zero coding in less than 30 seconds (seriously) - typicode/json-server
Starred by 75.7K users
Forked by 7.3K users
Languages   JavaScript 91.7% | HTML 8.3%
🌐
GitHub
github.com › Ovi › DummyJSON
GitHub - Ovi/DummyJSON: DummyJSON.com provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend. · GitHub
DummyJSON.com provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend. - Ovi/DummyJSON
Starred by 2.7K users
Forked by 283 users
Languages   EJS 46.4% | JavaScript 43.6% | SCSS 9.8% | Dockerfile 0.2%
Find elsewhere
🌐
Beeceptor
app.beeceptor.com › mock-server › dummy-json
Dummy JSON Rest API - Mock API
Transition to Beeceptor and enjoy ... testing. This mock server offers various REST Endpoints filled with JSON data or entities, perfect for frontend or app development using your preferred frameworks and libraries....
🌐
npm
npmjs.com › package › dummy-json
dummy-json - npm
April 3, 2022 - If the generated output is a valid ... const obj = JSON.parse(result); A common use of Dummy JSON is to create a mock API endpoint that returns random data....
      » npm install dummy-json
    
Published   Apr 03, 2022
Version   3.0.5
Author   Matt Sweetman
🌐
Stoplight
blog.stoplight.io › home › json generator for mock api data
JSON Generator for Mock API Data | Stoplight
November 10, 2023 - Many of the reasons you’ll want ... an API server. For those situations, one-off data may suffice. You can quickly generate JSON using a tool created by Stoplight engineer Vazha Omanashvil. When loaded, it includes an extensive JSON template as an example. You can edit as needed and include your own JavaScript to tune the format you need for your dummy ...
🌐
DummyJSON
dummyjson.com › docs › products
Products - DummyJSON - Free Fake REST API for Placeholder JSON Data
fetch('https://dummyjson.com/products/add', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: 'BMW Pencil', /* other product data */ }) }) .then(res => res.json()) .then(console.log); Show Output
🌐
GitHub
github.com › webroo › dummy-json
GitHub - webroo/dummy-json: Generates random dummy JSON data in Node.js
If the generated output is a valid ... const obj = JSON.parse(result); A common use of Dummy JSON is to create a mock API endpoint that returns random data....
Starred by 376 users
Forked by 61 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
DummyJSON
dummyjson.com › docs › users
Users - DummyJSON - Free Fake REST API for Placeholder JSON Data
fetch('https://dummyjson.com/user/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: 'emilys', password: 'emilyspass', expiresInMins: 30, // optional, defaults to 60 }), }) .then(res => res.json()) .then(console.log); Show Output
🌐
DEV Community
dev.to › roshan_100kar › display-dummy-api-json-data-to-a-table-in-react-js-3702
Display Dummy API JSON data to a table in React JS - DEV Community
September 4, 2022 - Hello There In order to Display Dummy API data in table form using react js you have knowledge about... Tagged with react, api, javascript, json.
🌐
Mocki
mocki.io › fake-json-api
Fake API - Dummy User and Todo API - Create Your Own
Access ready to use fake and dummy APIs with JSON data such as users and todos. Create your own fake API using Mockis interactive API editor.
🌐
DummyJSON
dummyjson.com › docs › todos
Todos - DummyJSON - Free Fake REST API for Placeholder JSON Data
fetch('https://dummyjson.com/todos/add', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ todo: 'Use DummyJSON in the project', completed: false, userId: 5, }) }) .then(res => res.json()) .then(console.log); Show Output
🌐
Json Data API
jsondata.reactbd.com
Json Data API - Free Fake JSON Data & Mock API for E-commerce Development
JsonData API provides free fake JSON data and mock API endpoints for e-commerce development. Use dummy products, users, carts, and orders for testing, prototyping, and learning. No authentication needed—free REST API for developers.
🌐
DEV Community
dev.to › tobidelly › building-a-simple-load-more-data-button-with-react-using-dummy-json-mie
Building a simple load more 'data' button with REACT using dummy JSON - DEV Community
August 29, 2024 - loading: Manages the loading state, indicating whether data is currently being fetched. products: Holds the array of product data fetched from the API. count: Tracks the number of times the "Load More Products" button is clicked, which is used to calculate how much data to skip in the API call. disableButton: Disables the "Load More Products" button after a certain number of products have been loaded (100 in this case). ... javascript async function fetchProducts() { try { setLoading(true); const response = await fetch( `https://dummyjson.com/products?limit=10&skip=${count * 10}&select=title,price,thumbnail` ); const result = await response.json(); if (result && result.products && result.products.length) { setProducts((prevData) => [...prevData, ...result.products]); setLoading(false); } console.log(result); } catch (e) { console.log(e); setLoading(false); } }
🌐
Reddit
reddit.com › r/javascript › anyone have a favorite free service that has dummy json that can be queried over http?
r/javascript on Reddit: Anyone have a favorite free service that has dummy JSON that can be queried over HTTP?
January 28, 2017 -

When testing non-application-specific code (like middleware or generic architecture), I often would like to have something like placehold.it but for JSON. Something I can perform HTTP requests against when I don't necessarily care about what type of data I get back, as long as I get something. Do any of you know of a service like that?