This is a simple API integration using RESTful methods(GET,POST,PUT,DELETE) and with built-in common end-points we usually use on our applications.
The package consists of two Classes:
- ArcanysApiClient - index.js
- User which extends ArcanysApiClient - user.service.js
This package uses a number of open source projects to work properly:
- AngularJS 1.x - HTML enhanced for web apps!
- ES6 - making javascript an OOP place!
And of course this package itself is open source located at Github
$ cd yourAppRoot
$ npm install arcanys-angular-api --save
Import the library
import User from 'arcanys-angular-api';
Then register it as service
angular.module('myApp', []).service('User', User);
On your controller, you need to inject Angular's $http to the package:
this.User.setHttp($http);
Then you set the urls for each built-in end-point
this.User.setLoginUrl('http://url-address/login');
Finally, use the built-in functions
this.User.login(data).then(
(response) => {
setTimeout(() => {
this.success(response.data);
},3000);
},
(error) => {
this.fail(error.data);
}
);
LOGIN
- setLoginUrl(url)
- login(data)
CONFIRM
- setConfirmUrl(url)
- confirm(data)
REGISTER
- setRegisterUrl(url)
- register(data)
SEND EMAIL
- setSendEmailUrl(url)
- sendEmail(data)
RECOVER PASSWORD
- setRecoverUrl(url)
- recoverPass(data)
RESET PASSWORD
- setResetPassUrl(url)
- resetPass(data)
- setHttp($http)
- setContentType('application/json')