diff --git a/freechat-client/src/channels.js b/freechat-client/src/channels.js index 9259119..efab70c 100644 --- a/freechat-client/src/channels.js +++ b/freechat-client/src/channels.js @@ -1,4 +1,5 @@ // Requesting channel data here +const { ipcRenderer } = require('electron') const auth = require('./auth.js') const { Request } = require('./request.js') @@ -20,30 +21,30 @@ class Channel { * @param {Object} params | basic object with jwt + id fields */ function channels_list(domain, port, params) { - const url = `http://${domain}:${port}/channels/list` // input sanitzation is for bitches - Request('get', url, params).then( - response => { - const channels = response.body - console.log(channels) + + Request('get', domain, port, '/channels/list', params).then( + channels => { + // fill the DOM with stuff here + console.log('sucess', channels) }, reason => { + console.log('Request for /channels/list rejected', reason) } ) } /** - * Only requests + * Listener callback for actually getting a list of channels * @param {Object} server_conf Should contain at least id/secret + domain/port * */ exports.get_channels = function(server_conf) { // the first two checks are here to rpevent getting a 401 due to a bad/missing jwt - if('jwt' in server_conf) { - if(auth.valid_jwt(server['jwt'])) { - const params = { jwt: server['jwt'], id: server['id'] } - } - // do something else idk - } else { - // complain here + console.log(server_conf) + const params = { + id: server_conf['id'], + jwt: server_conf['jwt'] } + + channels_list(server_conf['domain'], server_conf['port'], params) }