Fetch() POST requests IV


I’ve passed the instructions up to this point. Though when I press the shorten button, I do not get a response.!
please see screen shot.


Please remember to include a link to the exercise so we can work with the actual code. Post your raw code, as well as any error messages.


sorry, https://www.codecademy.com/courses/intermediate-javascript-requests/lessons/requests-ii/exercises/fetch-post-requests-iv?action=resume_content_item&course_redirect=introduction-to-javascript

// Information to reach API5b1f270479ab48a4bca52b064c691d3a
const apiKey = ‘<5b1f270479ab48a4bca52b064c691d3a>’;
const url = ‘https://api.rebrandly.com/v1/links’;

// Some page elements
const inputField = document.querySelector(’#input’);
const shortenButton = document.querySelector(’#shorten’);
const responseField = document.querySelector(’#responseField’);

// AJAX functions
const shortenUrl = () => {
const urlToShorten = inputField.value;
const data = JSON.stringify({destination: urlToShorten});
headers: {
‘Content-type’: ‘application/json’,
‘apikey’: apiKey,
body: data
}).then(response => {
if (response.ok){

// Clear page and call AJAX functions
const displayShortUrl = (event) => {

shortenButton.addEventListener(‘click’, displayShortUrl);

I passed instruction 2. Yet, after I paste an url and press shorten nothing happens.


Google has terminated support for the URL shortener so this API will no longer work.

Remove your credentials from the posted code but keep a record since those are Google related, not CC.