There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I interpreted this as await halts/pauses the current async request, and continues moving through the message queue until the promise is resolved, then the async request continues.
So, rather than waiting for the request to finish before doing anything else, it puts a hold on the action that may take some time to complete, continues with the rest of the queue, then resumes the held action when the promise is ready. Hope this helps.
when we use the POST it requires an object somtimes its {cache: no-cache} or JSON.stringify({id:200}) and somtimes its simply doesnt exist. what is this Object and what is it used for?
why the object above is not required and why in ‘POST’ we need to add mehtod body’ headers?
what is shortened Url is for? every time i tried in the exercise to see any results when i put diffrent URL’s in the inbox i dont see anything changed, i swear i did everthing by the orders.
I am newbie as well but I will try to explain what I have undertood so far about requests:
A request is the action you wish to carry out in a server, the most important actions are expressed by HTTP verbs :
‘GET’ => when you want to receive data from a server
‘POST’ => when you want to send data into a server
‘PUT’ => when you want to update data in a server
‘DELETE’ => when you want to delete data
(There are at least five more according to MDN Web Docs => ‘HEAD’, ‘CONNECT’, ‘OPTIONS’, ‘TRACE’ and ‘PATH’).
The method fetch has two arguments, the first one is the url of the server and it is compulsatory. If a second argument is not specified, the values by default are => method: ‘GET’ , headers: ’ ’ and body: ’ '.
Depending on the type of HTTP verb and the requirements of the server, you will have to change the values by default of the second argument.
For instance, if you want to retrieve data but the server requires you to identify, the property “headers” must be changed and place your API key. In datamuse they did not require us to identify, so no headers needed.
If you want to send data you have to specify method: ‘POST’, because the default value is ‘GET’. And obviously, you have to send this data, whis is attached to the property body. But before being attached, it should be tranformed from a JavaScript object into a JSON string, and this is done by using the method JSON.stringify(). This is the format the HTTP protocol demands for the body.
In the case of shortened URL the data we send (attached to body) it is the url we want to be shortened. Copy any link and paste it into input. Then click submit and your shortened url should be displayed in text-area.
I believe the halting refers to the carrying out the function where async is used. So, while this function is halted the rest of the program doesn’t have to wait for it to resolve, but rather, runs in parallel. I’m not sure what the message que is though, can anyone clarify that part?