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
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
write your fetch in an useEffect and set its response in a state
const [data, setData] = useState()
useEffect(() => {
fetch('API_URL', {method:"GET"})
.then(res => {
return JSON.parse(res);
}).then(response => {
setData(response)
})
}, [])
Videos
ยป npm install dummy-json