lincolnloop / amygdala Goto Github PK
View Code? Open in Web Editor NEWRESTful HTTP client for JavaScript powered web applications
License: BSD 3-Clause "New" or "Revised" License
RESTful HTTP client for JavaScript powered web applications
License: BSD 3-Clause "New" or "Revised" License
Hi,
can i use this in non node environment? (only client side)
Just what I have been looking for. Would there be bower support soon? Thanks
From the docs
// Get the list of active users from the local cache
var users = store.findAll('users', {'active': true});
What happens if the localstorage returns nothing, for example, its the first access, does it trigger a get on the remote resource? Thanks
Use cases:
This can be achieved via query parameters right now, but may not be a fit for everyone and requires a certain type of structure for the API endpoints that may not be possible to change.
I have the fallowing instance configured:
this.store = new Amygdala({
'config' : {
'apiUrl' : 'http://localhost:8081',
'idAttribute': 'url',
},
'schema' : {
'plans' : {
'url' : '/plans/'
}
}
});
this.store.get('plans', {'url': 'myid'})
resolves correctly to http://localhost:8081/plans/myid
but
this.store.update('plans', {'url':'myid', data:data})
resolves to http://localhost:8080/myid
The webserver serving the app is running on http://localhost:8080 while a I have the REST API on http://localhost:8081
.find('users', 1) doesn't return anything. You need to parse the number in as a string
.find('users', '1')
The find function doesn't have support for numerical ids. Possible to just change line 503
} else if (Object.prototype.toString.call(query) === '[object String]') {
to
} else if (Object.prototype.toString.call(query) === '[object String]' || Object.prototype.toString.call(query) === '[object Number]') {
Cheers
Paul
ps nice little library, lots of potential.
I have deletePlace function in my project. When I send DELETE without authorization to some resource server I've got the error 401, how can I catch errors in amygdala?
this.deletePlace = function(place_id) {
return store.remove('places', {
'id': "/" + place_id
}).done(function() {
ee.emit('change');
})
}
Error example caused by lack of authorization
DELETE http://localhost/api/v1/places/qx9143jmj7 401 (Unauthorized)
XHR finished loading: DELETE "http://localhost/api/v1/places/qx9143jmj7"
Uncaught #<XMLHttpRequest>
I can't seem to figure out how to build urls that follow the /api/endpoint/(id) pattern. It seems this library does it by doing /api/endpoint?id=1 instead. Does this library not support the former pattern?
Do you have experience about handling big data sets?
I found this blog post: http://josh.zeigler.us/technology/web-development/how-big-is-too-big-for-json/
Do you have numbers like that with Amygdala ?
Django will redirect if missing trailing slashes, but this will only work for GET. Redirects will also not work if doing a cross origin request while developing (eg localhost:4000 -> localhost:8000)
Right now it throws an unhelpful:
Uncaught TypeError: Cannot read property 'parse' of undefined amygdala.js:60
Amygdala._set
The FR is for auth in mind. Most APIs that use authentication require you to append a token on every request either as a query param or in the post body. Setting that to a variable in the config object would be super convienient for calling an api behind oauth2.
Is it possible to get access to the response and request objects? I need access to HTTP status but I'm not seeing how.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.