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
2020-02-20 08:30:27 +01:00

54 lines
1.2 KiB
JavaScript

'use strict';
const reqwest = require('reqwest');
const TYPE = 'json';
const CONTENT_TYPE = 'application/json';
const StrategyAPI = {
createStrategy (strategy, cb) {
reqwest({
url: 'strategies',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(strategy),
error (error) {
cb(error);
},
success () {
cb(null, strategy);
},
});
},
removeStrategy (strategy, cb) {
reqwest({
url: `strategies/${strategy.name}`,
method: 'delete',
type: TYPE,
error (error) {
cb(error);
},
success () {
cb(null, strategy);
},
});
},
getStrategies (cb) {
reqwest({
url: 'strategies',
method: 'get',
type: TYPE,
error (error) {
cb(error);
},
success (data) {
cb(null, data.strategies);
},
});
},
};
module.exports = StrategyAPI;