This community-built FAQ covers the “fetch() Post Requests III” exercise from the lesson “Requests II”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Web Development
Introduction To JavaScript
FAQs on the exercise fetch() Post Requests III
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!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
Does the order of properties matter when concerning the object we pass into fetch()?
In the fetch() Post Requests III exercise
, there is a requirement to create a variable called data and assign it the property ‘destination: urlToShorten’.
const data = JSON.stringify({destination: urlToShorten});
Why does the property / argument need to be in curly braces?
nevermind. Its because we are passing it an object
2 Likes
headers: {
'Content-type': 'application/json',
'apikey': apiKey
Why are the property names in the headers object in quotations?
5 Likes
I had a quick look through the documentation & stackoverflow and couldn’t find anything. Here’s the doc for reference - https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Headers.
Would be good to get some feedback from the moderators…
If we are using other APIs and we want to create const data, who will we know which object to pass into JSON.stringify(). As of current, the key-value is destination and the url, but what about the future?
This is really frustrating because we just follow some instructions without having the understanding of why we are doing it and this is not helpful at all.
const data = JSON.stringify({destination: urlToShorten}); what this variable is doing?
in the argument of the fetch API what is the purpose of these properties and object nested?
headers :{ 'Content-type': 'application/json',
'apikey': apiKey
},
body: data
4 Likes
Why don’t we have to include the workspace property in our headers for our POST request? It’s in the Rebrandly API.
Cause it’s javascript object notation (JSON), Resource: MDN(JSON) .
The format of data to be sent to a specific API depends on the API provider(You should read the documentation for that API carefully).
Some APIs expect Array data structures in JSON format while most expects Objects.
Hope this helps 
1 Like
Yes.
Here’s the order you always have to follow when passing in arguments into the fetch()
function:
1 - The URL that you are sending a POST / GET request to
2 (Only if you are sending a POST request) - An object containing information that the API needs
As you learned in previous lessons, JSON is very close to JavaScript objects, however, one noticeable difference is that properties are always wrapped in quotation marks
Are we using : instead of = because the subject is a property and not a variable?
i.e. method: ‘POST’ instead of method = ‘POST’