Newbie Rest question

I am trying to connect to my simple rest service and I have a blank page created with a datagrid.
I can see on the webservice side that it received the request and I can see in chrome developer
tools that the data was returned. however every my data grid stays empty. any help here would be appreciated.

data returned from the webservice

{
"todo1": {
"task": "build an API"
},
"todo2": {
"task": "?????"
},
"todo3": {
"task": "profit!"
}
}

pn
grid invoke

my grid invoke is

Hi @cmhdev,

Is the DataGrid data property bound to todoResult?

Best Regards,
Vladimir

Yes it is.

Hi,

Please zip your app meta folder and send it to us at info@radzen.com to check locally what’s going on.

Best Regards,
Vladimir

Thanks for your help enchev. this forum is saying I can’t upload files because i’m a new user. can you change something to allow me to attach the zip ?

Please send it to info@radzen.com.

Hi,

I’ve checked your API and indeed such data is not supported by the DataGrid component. The grid expects array of objects with with same properties for every object instance similar to books in your api.py. Possible solution is to transform the the returned data to array of objects before binding the DataGrid.

Best Regards,
Vladimir

Here is an updated application. There are a few things to consider:

  1. The sample service that you use doesn't support CORS. This would work only if the same origin policy is disabled.
  2. A transform is applied to the response so it is converted to array. The code is the following:

Object.keys(${result}).map(key => ${result}[key])

I could recommend using JSONPlaceholder for testing purposes. It comes with CORS enabled and has "DataGrid"-friendly responses.

meta.zip (6.0 KB)

1 Like

Good point on the cors.

I Greatly appreciate the help, I will format my data to look like the
jsonholder data.