1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/stores/StrategyAPI.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-03-17 22:01:46 +01:00
var reqwest = require('reqwest');
var TYPE = 'json';
var CONTENT_TYPE = 'application/json';
var StrategyAPI = {
createStrategy: function (strategy, cb) {
reqwest({
url: 'strategies',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(strategy),
error: function(error) {
cb(error);
2015-03-17 22:01:46 +01:00
},
success: function() {
cb(null, strategy);
2015-03-17 22:01:46 +01:00
}
});
},
removeStrategy: function (strategy, cb) {
reqwest({
url: 'strategies/'+strategy.name,
method: 'delete',
type: TYPE,
error: function(error) {
cb(error);
2015-03-17 22:01:46 +01:00
},
success: function() {
cb(null, strategy);
2015-03-17 22:01:46 +01:00
}
});
},
getStrategies: function (cb) {
reqwest({
url: 'strategies',
method: 'get',
type: TYPE,
error: function(error) {
cb(error);
2015-03-17 22:01:46 +01:00
},
success: function(data) {
cb(null, data.strategies);
2015-03-17 22:01:46 +01:00
}
});
}
};
module.exports = StrategyAPI;