Closed roelnoort closed 5 years ago
Can you post here the complete log or error?
What I do is:
In the developer console the only thing that appears is this line:
Warning: Missing translation for key: "Cannot read property 'map' of undefined"
I traced this error by copying the source code for restClient.js
and running it from my computer rather than from the npm package.
This brings me to the mapResponse
function which crashes in the line marked below:
case GET_LIST:
response.data = response.data.map((_item) => { // crashes on this line
const item = _item;
if (idKey !== 'id') {
item.id = _item[idKey];
}
return _item;
});
return response;
For non-paginated requests the response.data
field does not exists.
So this line ends up calling .map
on an undefined
object. Like the error states.
Hope this is clear.
Note: right now I fixed the error by changing the above code to:
if (response.data) {
response.data = response.data.map((_item) => {
const item = _item
if (idKey !== 'id') {
item.id = _item[idKey]
}
return _item
})
} else {
response.total = response.length
response.data = response.map((_item) => {
const item = _item
if (idKey !== 'id') {
item.id = _item[idKey]
}
return _item
})
}
However, I want to be sure that there isn't a way that non-paginated requests are already supported. I also do prefer to work on the npm packager rather than on a local copy/fork of it. I'd be happy to submit a PR if that helps and my suggestion seems viable to you.
It seems that we didnt use non paginated services in feathers So I think your idea to support it is needed.
Some tips for the PR:
Would be great if you can do a PR.
@roelnoort do you have an update on this? if not maybe someone else can take it
@roelnoort here a PR #104 Can you check it out, if it solves your issue?
Hi, when working with non-paginated feathers services I am getting the error "Cannot read property 'map' of undefined".
Does ra-data-feathers support working with non-paginated requests, maybe by setting an option in for the feathers services that do not have pagination?