Bytesize API not working

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:


I’m in the "Requests with fetch API’ chapter in Javascript course and I have issues with the page.

in “Making an async POST Request” my code looks like this:

const apiKey = '<my key here>'; const url = ''; const inputField = document.querySelector('#input'); const shortenButton = document.querySelector('#shorten'); const responseField = document.querySelector('#responseField'); const shortenUrl = async () => { const urlToShorten = inputField.value; const data = JSON.stringify({destination: urlToShorten}); try { const response = await fetch(url, { method: 'POST', body: data, headers: { 'Content-type': 'application/json', 'apikey': apiKey } } ); if(response.ok){ const jsonResponse = await response.json(); renderResponse(jsonResponse); } } catch (error) { console.log(error); } } const displayShortUrl = (event) => { event.preventDefault(); while(responseField.firstChild){ responseField.removeChild(responseField.firstChild); } shortenUrl(); } shortenButton.addEventListener('click', displayShortUrl);

The codecademy checks my code as correct and I can move to the next exercise but the bytesize page doesn’t shorten my urls(I made sure to include http:// or https://).
I had the same issue in the previous steps, I completed the exercise and could move forward but the API is not working.

Is it an issue with the website or can you see any issue with my code?

It seems that if the code wasn’t working I shouldn’t be able to move to the next exercise.

Thank you to anyone that could help me with this.

your code worked when I tried it. ( I shortened ).

try to replace with your api key this part: “”, including the angle brackets. it should work then. let me know if it worked for you