Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

377
Vistas
I'm following a tutorial and get an uncaught Syntax error in promise while the code in the video works just fine, Please look into it

I'm a learner on currently following a YouTube tutorial on JS, And the below code worked fine in the video, but I get an error message

error: Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Console log shows the line which has the code console.log("finished!"); as the line with the error

The JS code:

const getDataFromForm = () => {
  const requestObj = {
    firstName: "Humaid",
    lastName: "Ahamed",
    categories: ["nerdy"],
  };
  return requestObj;
};

const buildRequestUrl = (requestData) => {
  `http://api.icndb.com/jokes/random?firstName=${requestData.firstName}&lastName=${requestData.lastName}&limitTo=${requestData.categories}`;
};

const requestJokeAnotherMethod = async (url) => {
  const Response = await fetch(url);
  const jsonResponse = await Response.json();
  const joke = jsonResponse.value.joke;
  postJokeToPage(joke);
};

const postJokeToPage = (joke) => {
  console.log(joke);
};

const processJokeRequest = async () => {
  const requestData = getDataFromForm();
  const requestUrl = buildRequestUrl(requestData);
  await requestJokeAnotherMethod(requestUrl);
  console.log("finished!");
};

processJokeRequest();
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I've notice that I've forgot to return the Chuck Norris API link, Now the code works like charm, Thank you for that person that pointed out my mistake

I had previously not included the return statement in the below function:

const buildRequestUrl = (requestData) => {
  return `http://api.icndb.com/jokes/random?firstName=${requestData.firstName}&lastName=${requestData.lastName}&limitTo=${requestData.categories}`;
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda