Why Is My Function Returning A Promise And Not An Object From My Db?
I have the following below 2 functions attempting to get data out of a mongo database from an express server endpoint I have set up. This code is in my React front-end app. export
Solution 1:
The data.json()
call is actually returning a promise by design. Take a look at the documentation page here for an explanation as to why.
You can fix it by chaining another then
call or by declaring your function as async
and using await
.
Post a Comment for "Why Is My Function Returning A Promise And Not An Object From My Db?"