0
function fetchSync(url, data, headers={ 'Content-Type': 'application/json' })
{
    var responseData = {}
    fetch(url, { method: 'POST', headers, body: JSON.stringify(data) }).then(async (data) => {
        Object.assign(responseData, data)
        responseData.jsonData = await responseData.json()
    }).catch((error) => {
        console.error(error)
        responseData.jsonData = null
    })
    while (responseData.jsonData === undefined);
    return responseData
}

I'm not very proficient in English, so I hope you understand that I may not be able to provide detailed explanations.

It couldn't escape the while loop

VLAZ
  • 26,331
  • 9
  • 49
  • 67

0 Answers0