Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!