When trying to resolve my promise, I get the error "Objects are not valid as a React child (found: [object Promise])."
In the console.log after my API request in GetCardsFromBoard(), the typeOf() my response is string and it prints out the data to the console. But in TrelloTester(), the console shows that my response is still Promise<pending>
and I get the error.
I've tried so many configurations but I can't get my promise to resolve, thanks for any help!
const fetch = require('node-fetch');
export async function GetCardsFromBoard(board) {
let cards = await fetch(
baseURL+'boards/'+board+'/cards?key='+key+'&token='+token,
{
method: 'GET',
headers: {
'Accept': 'application/json'
}
})
.then(response => {return response.text()})
.catch(err => console.error(err));
console.log(typeof(cards), cards); //prints "string" type and then the entire json response
return cards;
}
export function TrelloTester() {
let bodyStr = GetCardsFromBoard(boardID);
console.log("resp: ", bodyStr); //shows Promise<pending>, but with the correct response value inside
return (
<BigCard header=" " body={bodyStr}/>
);
}
export default TrelloTester;