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

214
Visualizações
Fetching JSON in JS from Flask app gives JSON.parse error

I have a Python Flask app setup like this:

@app.route("/")
def getlist():
    data = jsonify({"test": True, "name": "User",
                    "teststring": "Hello, World!"})

    return data

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5050, debug=True)

Its a very simple one that returns a jsonified dictionary on the root (/) of domain. I hosted this site as you can see on localhost:5050. Now when I use JavaScript to fetch this JSON using the fetch api like this:

fetch("http://localhost:5050", {
    mode: "no-cors", // I added this due to some other error, called cross origin something
})
    .then((blob) => blob.json())
    .then((data) => console.log(data));

I get this error in this console:

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

but the Network tab shows 200 OK

network status response

about 4 years ago · Juan Pablo Isaza
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