title: POST request on fetch is returning a 400 (read question)
body: <p>I have a question.</p>
  <p>I am using the <code>fetch</code> API for JS, and am trying to send a POST request to a server. However, the server responds with a 400, or &quot;bad request&quot;. The server in question is a flask webserver.</p>
  <p>The code:</p>
  <pre><code>fetch('https://webserver.com/post', {
          method: &quot;POST&quot;, 
          body: JSON.stringify(data)
      })
      .then(alert('Post created!'))
  </code></pre>
  <p>where <code>data</code> is a global variable containing my data that I want to send in the request.</p>
  <p>The server code (in Python):</p>
  <pre><code>@app.route('/post', methods=['POST'])
  def newpost():
      data1 = request.form['data1']
      data2 = request.form['data2']
      data3 = request.form['data3']
      if data1 in list(db.keys()):
          resp = Response('error')
      else:
          db[data1] = [data2, data3]
          resp = Response('Success')
      resp.headers['Access-Control-Allow-Origin'] = '*'
      print('yep we got a post request')
      return resp
  </code></pre>
  <p>and here, <code>db</code> is my database.</p>
  <p>What should be happening is the server send back a 200, and saves the data in the database. Does anyone know why I am getting the 400, and how to fix it?</p>