Comments (3)
I thought about this, too. But there is a method called HttpAgent#clone
, which can be used to generate a copy of the agent.
I use it like this (to delete multiple products by id):
var products = new HttpAgent('/api').navigate('products');
[1,2,3,45].forEach(function(id) {
var copy = products.clone();
copy.navigate({"id": id}, 'self').delete();
});
from hateoas-client-js.
I saw the .clone()
method and realised this was its purpose. I just feel that if I give you a HttpAgent
for products you should be able to call it and get products.
As it is I could call navigate and that agent I gave you no longer points to what you think it points to.
Do you support templates URLs?
{
"_links": {
"product": { "href": "/api/product/{id}", "isTemplated": true }
}
}
Then agent.navigate('product', {"id": 1})
would generate /api/product/1
??
On 30 Jun 2014, at 20:35, DracoBlue [email protected] wrote:
I thought about this, too. But there is a method called HttpAgent#clone, which can be used to generate a copy of the agent.
I use it like this (to delete multiple products by id):
var products = new HttpAgent('/api').navigate('products');
[1,2,3,45].forEach(function(id) {
var copy = products.clone();
copy.navigate({"id": id}, 'self').delete();
});
�
Reply to this email directly or view it on GitHub.
from hateoas-client-js.
Nope. Templated URLs are not supported, yet.
If you do:
agent.navigate('products', {'id': id});
it is the same like:
agent.navigate('products')
agent.navigate{'id': id});
It will fetch products and filter all results for an entity with the
property id
set to the desired value.
See
https://github.com/DracoBlue/hateoas-client-js/blob/master/example/buy_coffee.html
for
an example.
I know that this is not templated URIs, but that's the reason why the
second parameter for navigate is already taken ;)
If you want to append query parameters, you can do it like this:
agent.navigate('product').get(function(response) {
}, {"id": id});
This will append ?id=1225 to the product link of the agent.
from hateoas-client-js.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hateoas-client-js.