https://github.com/txbm/angular-http-api
A basic http api provider for making parameterized async http calls and getting back usable values.
https://github.com/txbm/angular-http-api
Last synced: about 1 month ago
JSON representation
A basic http api provider for making parameterized async http calls and getting back usable values.
- Host: GitHub
- URL: https://github.com/txbm/angular-http-api
- Owner: txbm
- Created: 2014-07-06T07:18:31.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-07-09T10:56:43.000Z (almost 12 years ago)
- Last Synced: 2025-03-17T14:42:54.868Z (about 1 year ago)
- Language: JavaScript
- Size: 211 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Angular HTTP API
[](https://coveralls.io/r/petermelias/angular-http-api?branch=master)
[](https://travis-ci.org/petermelias/angular-http-api)
[](https://david-dm.org/petermelias/angular-http-api.svg)
[](http://badge.fury.io/js/angular-http-api)
The purpose of this library is to provide a very light API for making parameterized URL requests to an API server.
### Installation
```bash
npm install angular-http-api
# or
bower install angular-http-api
```
### Usage
```javascript
var app = angular.module('testApp', ['httpApi']);
app.config(function (httpApiProvider) {
httpApiProvider.setHost('google.com');
httpApiProvider.preferScheme('https');
});
app.factory('UserService', function (httpApi) {
return {
lookupUser: function (email) {
httpApi.get('/user/:email', {email: email});
},
searchUser: function (name) {
httpApi.get('/user/search', {}, {firstName: name});
}
};
});
app.controller('testCtrl', function (UserService) {
$scope.user;
$scope.matching = [];
UserService.lookupUser('petermelias@gmail.com').then(function (user) {
$scope.user = user;
});
// GET: https://google.com/user/petermelias@gmail.com
UserService.searchUser('Peter').then(function (matches) {
$scope.matching = matches;
});
// GET: https://google.com/user/search?firstName=peter
});
```
### License
MIT