Hi! I'm trying to fetch data inside an Await tag in React, but the promise doesn't resolve and thus I can't get my data. Any ideas? Here're some useful screen shots: and my get function from the api is :
export async function getHostBooks(){
const res = await fetch("/api/host/Books");
if (!res.ok){
throw {
message:'Failed to fetch host books',
statusText:res.statusText,
status: res.status
}
}
const data = await res.json();
return data.books;
}
My fake mirage server end point is :
this.get('/host/Books', () => {
//console.log('we are in the second get.')
return books.filter(x=>x.hostId==='123')
})
But I'm pretty sure I get the right response from the fake server.. Thanks for your help!