You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
The company I am working for doesn't follow a restful pattern e.g. api/courses/abc doesn't return a course... it actually returns a wrapped object with a course inside
This is along the lines of {"operationSucceeded": true, "data": data, "notifications": []}
This causes an error as the item can't be found in the collection (because the collection is a level down)
e.g. collection.data rather than collection
Ok. So I have extended the service and used the get(reqInfo: RequestInfo) {} method
I have set const collection = reqInfo.collection.data;
It then finds the object correctly but I need to wrap this back up in the same object format. So i do
const options: ResponseOptions = data ?
{
body: {"operationSucceeded": true, "data": data, "notifications": []},
status: STATUS.OK
} :
{
body: { error: 'id='${id}' not found },
status: STATUS.NOT_FOUND
};
(As shown in your hero-in-mem-data-override.service.ts)
The built options look ok but my http subscription callback blows up with the following
"TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable"
Do you have any advice? Am I creating the body wrong?
The text was updated successfully, but these errors were encountered:
This may be a HowTo rather than an issue.
The company I am working for doesn't follow a restful pattern e.g. api/courses/abc doesn't return a course... it actually returns a wrapped object with a course inside
This is along the lines of {"operationSucceeded": true, "data": data, "notifications": []}
This causes an error as the item can't be found in the collection (because the collection is a level down)
e.g. collection.data rather than collection
Ok. So I have extended the service and used the get(reqInfo: RequestInfo) {} method
I have set const collection = reqInfo.collection.data;
It then finds the object correctly but I need to wrap this back up in the same object format. So i do
const options: ResponseOptions = data ?
{
body: {"operationSucceeded": true, "data": data, "notifications": []},
status: STATUS.OK
} :
{
body: { error:
'id='${id}' not found
},status: STATUS.NOT_FOUND
};
(As shown in your hero-in-mem-data-override.service.ts)
The built options look ok but my http subscription callback blows up with the following
"TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable"
Do you have any advice? Am I creating the body wrong?
The text was updated successfully, but these errors were encountered: