In my use of oneUrl I found that the route name is used to create the URL for subsequent PUT and DELETE operations. For example (pseudo code):
// "GET /api/v2/users/3/ HTTP/1.1" 200 184 var user = Restangular.oneUrl('myuser', 'http://localhost:8000/api/v2/users/3').get(); user.name = 'Fred'; // the following uses the route name and not the URL: // "PUT /api/v2/myuser HTTP/1.1 404 100 user.put();
I was surprised by this behavior. I expected put() to use the same URL as get() ; which would be useful in my case.
My API uses absolute URLs in JSON payload data to go to all related resources, and I wanted to use instances of oneUrl() to GET/PUT without re-creating the routes in the JS code. But I'm pretty new to Restangular, so I may not have the mental model correctly.
saschwarz
source share