fleet/frontend/kolide/websockets.js
Mike Stone d747a471af Refactor API client (#1335)
* Isolate each API entity
* Improve code structure in API client and request mocks
* Standardize on a request mock structure
* Use helper for creating request mocks
* Adds Request class to handle API requests
2017-03-02 17:07:01 -05:00

23 lines
621 B
JavaScript

import SockJS from 'sockjs-client';
import local from 'utilities/local';
export default (client) => {
return {
queries: {
run: (campaignID) => {
return new Promise((resolve) => {
const socket = new SockJS(`${client.baseURL}/v1/kolide/results`, undefined, {});
socket.onopen = () => {
socket.send(JSON.stringify({ type: 'auth', data: { token: local.getItem('auth_token') } }));
socket.send(JSON.stringify({ type: 'select_campaign', data: { campaign_id: campaignID } }));
};
return resolve(socket);
});
},
},
};
};