Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda