[sqlalchemy] Re: Flask API returns JSON but gives an error in React: Error: Objects are not valid as a React child

2020-08-20 Thread Dale Preston
I just realized I posted this in sqlalchemy but it's a React issue. Sorry for the confusion. I'll find an appropriate React group somewhere. Dale On Thursday, August 20, 2020 at 1:23:22 PM UTC-5 Dale Preston wrote: > Just more info; if I change res => res.json() to res => res.text(), I get

[sqlalchemy] Re: Flask API returns JSON but gives an error in React: Error: Objects are not valid as a React child

2020-08-20 Thread Dale Preston
Just more info; if I change res => res.json() to res => res.text(), I get the json as text. *{ "users": [ { "emailaddress": "bobsm...@somedomain.com", "firstname": "Bob", "lastname": "Smith", "userid": "bsmith" }, { "emailaddress": "tomjones @otherdomain.com", "firstname": "Tom", "lastname":

[sqlalchemy] Flask API returns JSON but gives an error in React: Error: Objects are not valid as a React child

2020-08-20 Thread Dale Preston
I have a flask API that returns valid JSON. The Content-Type is application/json. I assign it to state using useEffect. When I call on the variable returned by useEffect, I get the error: *Error: Objects are not valid as a React child*. I know that React is reading the JSON because I get

Re: [sqlalchemy] Getting column data from result set with column name as a string.

2020-08-20 Thread Simon King
If you want to get an attribute of an object where the name of the attribute is variable, you can use the getattr function: attrname = "lastname" column = getattr(User, attrname) for item in session.query(column): print(item) or: attrname = "lastname" for user in session.query(User):