JS не могу вернуть json из асинхронной функции с fetch()
Не могу понять, почему я немогу подождать ответ и вернуть json
console.log(getTestFlashCards(541034)); // выводится Promise { <pending> }
async function getTestFlashCards(testDocumentId) {
var response = await fetch(`https://naurok.com.ua/api/test/documents/${testDocumentId}/flashcard`,
{
method: 'POST',
headers: {
'Referer': 'https://naurok.com.ua/test//flashcard'
},
credentials: 'include'
});
var data = await response.json();
console.log(data); // выводится json
return data;
}