mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 18:28:55 +00:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import chrome from 'ui/chrome';
|
|
require('ui/modules')
|
|
.get('app/wazuh', [])
|
|
.service('apiReq', function ($q, $http, genericReq) {
|
|
return {
|
|
request: (method, path, body) => {
|
|
let defered = $q.defer();
|
|
|
|
if (!method || !path || !body) {
|
|
defered.reject({
|
|
error: -1,
|
|
message: 'Missing parameters'
|
|
});
|
|
return defered.promise;
|
|
}
|
|
|
|
let requestData = { method, path, body };
|
|
|
|
genericReq
|
|
.request('POST', '/api/wazuh-api/request', requestData)
|
|
.then((data) => {
|
|
if (data.error) {
|
|
defered.reject(data);
|
|
} else {
|
|
defered.resolve(data);
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
if (error.error) {
|
|
defered.reject(error);
|
|
} else {
|
|
defered.reject({
|
|
error: -2,
|
|
message: 'Error doing a request to Kibana API.'
|
|
});
|
|
}
|
|
});
|
|
|
|
return defered.promise;
|
|
}
|
|
};
|
|
}); |