Skip to content
This repository has been archived by the owner on Feb 15, 2018. It is now read-only.

Commit

Permalink
Add items route
Browse files Browse the repository at this point in the history
This does NOT work atm, sends the client into an infinite loop. Fun!
  • Loading branch information
tivac committed Aug 19, 2015
1 parent 05fdb1a commit 9e57027
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.html
Expand Up @@ -12,8 +12,9 @@

model
.get(
"items[100..120].name",
"items[100..120].buys['price', 'quantity']"
// "items[100..120].name",
// "items[100..120].buys['price', 'quantity']"
"items"
)
.then(function(response) {
document.write("<pre>" + JSON.stringify(response.json, null, 4) + "</pre>");
Expand Down
15 changes: 15 additions & 0 deletions router.js
Expand Up @@ -3,6 +3,21 @@
var axios = require("axios");

module.exports = require("falcor-router").createClass([ {
route : "items",
get : function(pathSet) {
console.log(pathSet);

return axios.get("https://api.guildwars2.com/v2/items")
.then(function(resp) {
return resp.data.map(function(id, idx) {
return {
path : [ pathSet[0], idx ],
value : id
};
});
});
}
}, {
route : "items[{integers:ids}]['name', 'type', 'level', 'rarity', 'icon']",
get : function(pathSet) {
return axios.get("https://api.guildwars2.com/v2/items?ids=" + pathSet.ids.join(","))
Expand Down

0 comments on commit 9e57027

Please sign in to comment.