Closed maheshnerella closed 7 years ago
Hello @maheshnerella, Can you please describe what do you mean by "When one of my service returns true as a response". Is it one of the endpoints? Also can you please provide more details about the issue.
I got the almost same problem too. the case is... when my service function get the base64 image string as a response. I am getting the below error. core.es5.js:1084 ERROR TypeError: Cannot create property 'route' on string 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ8AAACfCAYAAADnGwvgAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPue....=' at restangularizeBase (ngx-restangular.js:52) at restangularizeElem (ngx-restangular.js:182)
My restangular code is getProfilePicture(id:string){ return this.restangular.one('web').one('img').one('base64',id).get().map(res => { return res.json(); }); }
But it is no problem when i am using the angular/http package. the code as below:
getProfilePictureHttp(id:string){
return this.http.get(http://api.service.com/essapi/api/web/img/base64/${id}
).map(res => {
});
Hello @maheshnerella @paullauyc, restagular expects object in response. Then it extends this object with own fields and methods. Server should return Json as response e.g:
{
data: 'string or boolean'
}
Big Thanks.
It definitely doesn't make sense to create an artificial anonymous object to return a boolean value.
I think whenever an endpoint returns a boolean it should be handled as a service and not as a completely artificial object created just to hold a value. What's the use of the augmented methods to this object, anyway? Would it make any sense to call save()
or remove()
on objects like these?
core.es5.js:1020 ERROR TypeError: Cannot create property 'route' on boolean 'true' at restangularizeBase (ngx-restangular.js:52) at restangularizeElem (ngx-restangular.js:182) at SafeSubscriber.okCallback [as _next] (ngx-restangular.js:358) at SafeSubscriber.__tryOrUnsub (Subscriber.js:238) at SafeSubscriber.next (Subscriber.js:185) at Subscriber._next (Subscriber.js:125) at Subscriber.next (Subscriber.js:89) at CatchSubscriber.Subscriber._next (Subscriber.js:125) at CatchSubscriber.Subscriber.next (Subscriber.js:89) at MapSubscriber._next (map.js:83)