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

239
Vistas
JSON.parse: unexpected character at line 1 column 1 of the JSON data(django)

i was making an ecommerce website using django & trying to send data using fetch in javascript but this message is keep showing up. Tried 100 times to figure out what's the issue, but can't find one.

total = total bill ship = True means, shipping is necesarry because the product is not digital. form is a form where the user added their info

 var userFormData = {
      "name": "null",
      "email": "null",
      "total": total,
    };
    var shippingFormData = {
      "address": null,
      "city": null,
      "zipcode": null,
      "state": null,
    };
    if (user == "AnnonymousUser") {
      userFormData.name = form.name.value;
      userFormData.email = form.email.value;
    }
    if (ship == "True") {
      shippingFormData.address = form.address.value;
      shippingFormData.city = form.city.value;
      shippingFormData.zipcode = form.zipcode.value;
      shippingFormData.state = form.state.value;
    }
    console.log(userFormData);
    console.log(shippingFormData);
    var url = "/checkout_info_process/";
    fetch(url, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-CSRFToken": csrftoken,
      },
      body:JSON.stringify({
        "userform": userFormData,
        "shippingform": shippingFormData,
      }),
    })
      .then((response) => response.json())
      .then((data) => {
        console.log(data);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This error occurs when you parse the response of your request. This means that your backend is not sending back a JSON. Try

.then((response) => response.text())

instead.

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