React, Axios and Flask - AttributeError: 'NoneType' object has no attribute 'get' React, Axios and Flask - AttributeError: 'NoneType' object has no attribute 'get' flask flask

React, Axios and Flask - AttributeError: 'NoneType' object has no attribute 'get'


It looks like whatever you are returning from post_data = request.get_json() isn't returning the type of object you're trying to use the get() method from.

Try console logging the request object to see if you can see the JSON object attached to it.


A header with Content-Type and authorization bearer was missing. Once I did:

var headers = {          'Content-Type': 'application/json',          Authorization: `Bearer ${window.localStorage.authToken}`        }

and passed it like so:

axios.post(url, data, headers)

request.get_json() worked.