FAQ: Requests with Fetch API - Making a POST Request

This community-built FAQ covers the “Making a POST Request” exercise from the lesson “Requests with Fetch API”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Full-stack Engineering for your Business
Create a Front-End App with React

Learn Intermediate JavaScript

FAQs on the exercise Making a POST Request

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 (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 (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

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!

I can’t sign up for rebrandly. I’ve tried multiple times, cleared my cookies, and used multiple email addresses. I sign up, get a verification link, and then verify. But the moment I try to access the site, it jeeps telling me that I need to sign in, redirecting me to the sign in page over and over again.

1 Like

Same for me.
I cant’ login to Rebrandly.
I tried clearing cookies, deactivate all extensions. I tried with 3 different browsers.
I tried signing up with two different email providers, and I tried loging in directly with google button.

When i Click the Login button, the page loads and then ends up on a page written “You’re logged out”.

I can’t continue this Codecademy lesson…

1 Like

I am also having problems even signing up for a rebrandly account. The page hangs up at various points along the way and times out.

If I might make a suggestion: please don’t have lessons that rely on 3rd party websites for completion.

1 Like

What exactly is the body of a response or a request?

Same, rebrandly site doesn’t work, can’t get the api key

Worked for me just fine.

I couldn’t agree more! I don’t think it’s right that we have to sign up to another company just to get through the lesson. Some exceptions apply, of course (Github etc.), but at least with that they didn’t stop you being able to access the content you’ve paid for.

Maybe they could just have a “Read Only” button for these types of situations, where you can at least see what is going on in the rest of the lesson, even if you can’t complete it properly.

3 Likes

Why there is no feedback about this common problem?

I think it comes down to the fact that these forums are mainly for members to help other members; staff won’t be able to look through every thread just to see if there are any issues. If you want Codecademy to be aware of the problem, what I do is report it as a bug in the “Get Unstuck” part of the lesson itself. You won’t receive any feedback unfortunately, but I’d like to think that if enough people reported the same issue, they might do something about it.

1 Like

I’m hoping someone could kindly shed some light on the construction of the stringify method in the shoternURL function below)?

Specifically, I’m interested in knowing how the JSON.stringify function works and what the ‘destination’ item is pointing to in the object.

There wasn’t much of an explanation of the contents of this specific object in the lesson.

const shortenUrl = () => {
  const urlToShorten = inputField.value;
  const data = JSON.stringify({destination: urlToShorten});
  fetch(url,
    {
        method: 'POST',
        headers: {
                    'Content-type': 'application/json',
                    'apikey': apiKey
                },
        body: data
    });
}

I appreciate the help in advance!

It is pretty simple how JSON.stringify() works. Think of it as "A method that converts something related with JSON into a string. (Note that it’s only partially correct but for understanding purposes, it should be fine)

Consider an example (from MDN for further understanding:

console.log(JSON.stringify({ x: 5, y: 6 }, ));

The output would be "{"x":5,"y":6}". Can you guess how/why?

Consider another example from MDN:

console.log(JSON.stringify([new Number(3), new String('false'), new Boolean(false)]));
// consider on this: [new Number(3), new String('false'), new Boolean(false)]

The value will be changed to string, obviously. So our new value is: "[ ... ]".
The keyword new creates a new object. Consider the first element of the array i.e., new Number(3). A number object having the value of 3. Try expecting your output and then see if it matches the actual output

// Expected output: "[3,"false",false]"

For people having problems following the link in the exercise to get an api key, try going here instead:
API Key.

Then click the ‘your Rebrandly dashboard’ hyperlink, create an account (or log in if you have one), then finally go to the API tab to create your api key.