Answer the question
In order to leave comments, you need to log in
Synchronous ajax request - react?
You must first make a request to the server using ajax, wait for the result, and then draw the page based on the received data. How can it be implemented?
Answer the question
In order to leave comments, you need to log in
first make a request <...> and then render the page
Here's a pretty clear example from the official documentation. Instead of callbacks, you can use async/await , but the essence is the same
fetch('./api/some.json').then( function(resp){drawResp(resp)})
function drawResp(resp){
BrowserDrawMeBeautiful()
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question