Hi Can someone help me please, I'm probably doing something stupid here (blame having a cold) but I thought I'd ask on here while I "walk away" for a bit..
I'm messing around with Flask in Python and have a request coming from a React App (I'm also messing with)
Here is my example API call...
@app.route('/addnewclient', methods=['GET', 'POST'])
def addNewClient(dbName = 'customers'):
account_dict = request.form.to_dict()
print(account_dict)
The data I am sending from the app for example:
{name: 'Joe Bloggs'}
The above request.form.to_dict() prints it as :
{'{name: 'Joe Bloggs'}': ''}
Treating the entire data as the Key I guess... Its POST request and I've tried various other things like args or not using to_dict etc (ImmutableMultiDict).
What am I doing wrong here?
FYI, my javascript on the other side is:
const handleClick = async() => {
const API_URL = 'http://localhost:1000';
let path = '/addnewclient'
try {
const response = await axios.post(
API_URL + path,
JSON.stringify(form)
);
console.log(response.data)
} catch (error) {
console.error(error);
}
}