Pārlūkot izejas kodu

Update key service to use (err, data) callbacks

production
Jack Foltz pirms 5 gadiem
vecāks
revīzija
f0a7c05174
Parakstījis: foltik <jack@foltz.io> GPG atslēgas ID: 303F88F996E95541
1 mainītis faili ar 24 papildinājumiem un 21 dzēšanām
  1. +24
    -21
      app/public/services/KeySvc.js

+ 24
- 21
app/public/services/KeySvc.js Parādīt failu

@@ -1,37 +1,40 @@
var angular = require('angular');

angular.module('KeySvc', []).service('KeyService', ['$http', function ($http) {
this.getAllKeys = function (cb) {
angular.module('KeySvc', []).service('KeyService', ['$http', function($http) {
this.createKey = (identifier, scope, cb) =>
$http({
method: 'GET',
url: '/api/keys/get'
}).then(function (res) {
cb(res.data);
method: 'POST',
url: '/api/keys/create',
data: {
identifier: identifier,
scope: scope
}
}).then(res => {
cb(null, res.data)
}).catch(err => {
cb(err);
});
};

this.deleteKey = function (key, cb) {
this.deleteKey = (key, cb) =>
$http({
method: 'POST',
url: '/api/keys/delete',
data: {
key: key
}
}).then(function (res) {
cb(res.data);
}).then(res => {
cb(null, res.data);
}).catch(err => {
cb(err);
});
};

this.createKey = function (identifier, scope, cb) {
this.getAllKeys = cb =>
$http({
method: 'POST',
url: '/api/keys/create',
data: {
identifier: identifier,
scope: scope
}
}).then(function(res) {
cb(res.data);
method: 'GET',
url: '/api/keys/get'
}).then(res => {
cb(null, res.data);
}).catch(err => {
cb(err);
});
};
}]);

Notiek ielāde…
Atcelt
Saglabāt