Skip to content
Advertisement

Flask TypeError: ‘method’ object is not subscriptable

I am building a dictionary app with Flask where users can add new words, the code below is the app.py file, I am having issues with the POST request, the error I am receiving on my terminal is this:

JavaScript

This code below is the app.py file

JavaScript

here is my dashboard page or route:

JavaScript

Advertisement

Answer

get_json is the actual method, which, as the error says, is not subscribable (i.e., doesn’t support the [] syntax). You need to call it using parenthesis (()), and then subscript the return value.

You already saved the return value to req, now you just need to use it:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement