ajax-utils
v0.0.8
Published
Ajax wrapper using promises
Downloads
8
Readme
Simple Ajax Wrapper that uses promises
Example:
import * as Ajax from 'ajax-utils';
var req = new Ajax.Request('get', '/someurl/:id', {id: 3}); // url replace
req.headers = {
'ETag': 'something'
};
// This will transform the request and response
// {fooBar: 2} will be sent as {foo_bar:2} and the reverse transform applied
// to the response
req.transform = Ajax.Transform.CamelCaseToUnderscore;
req.applyReverseTransformToResponse = true;
req.send().then((response: Ajax.Response) => {
// do something with the response
var res = response.bodyJSON;
}).done();