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

112
Visualizações
POST request returns none in FLASK REST API

Hi I am currently trying to post to my python flask api.

In the frontend I have the following:

function onSubmit() {
  fetch(environment.api + "get-selection", {
    method: "POST",
    header: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(selection.value),
  });
  console.log(selection.value)
}

In the backend I am just trying to deal with it like this:

@routes.route("/get-selection", methods=["POST", "GET"])
def get_people():
  data = request.get_json()
  # data_json = data["target"]
  print(format(data))

  return "Hello World"

I am currently returning that string because otherwise I get the following error

Error Message

When printing data I just get None...

I already tried request.jsonand request.json()as well as request.get_json and nothing worked so far. For the ones asking how selection.value looks:

selection.value

I really cannot get my head around that problem and hope one of you might have an answers.

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