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
๐ŸŒ
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.
Docs
DummyJSON provides a free fake REST API with placeholder JSON data for development, testing, and prototyping. Access realistic data quickly for your projects.
Free Fake REST API for Placeholder JSON Data
REST Endpoints filled with Products 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.
๐ŸŒ
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
๐ŸŒ
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);
๐ŸŒ
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
Get a full fake REST API with zero coding in less than 30 seconds (seriously) - typicode/json-server
Starred by 75.6K users
Forked by 7.3K users
Languages ย  JavaScript 91.7% | HTML 8.3%
๐ŸŒ
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.
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ dummy-json
dummy-json - npm
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
๐ŸŒ
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 282 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....
๐ŸŒ
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
๐ŸŒ
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 ...
๐ŸŒ
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%
๐ŸŒ
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 โ€บ 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.
๐ŸŒ
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); } }
๐ŸŒ
Beeceptor
beeceptor.com โ€บ mock-api
JSON & XML Mock Server - Free
Paste JSON or XML and instantly get a mock server that behaves like the real service. Beeceptor turns your sample payloads into working mock servers. Start with static responses or apply 300+ smart data generators to produce dynamic, meaningful ...