Skip to content

Commit

Permalink
fix(api): add missing config check
Browse files Browse the repository at this point in the history
Signed-off-by: Johnny Estilles <johnny@estilles.com>
  • Loading branch information
estilles committed Nov 6, 2021
1 parent fd37a27 commit f00d85d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const generateUrl = (ip, port, cmd, param = '') => `http://${ip}:${port}/api/${c

module.exports = {
sendCommand({ cmd, param, timeout = 2000 }) {
if (this.config.ip === undefined) {
console.log('Error: Missing IP Address in instance config')
return Promise.reject('Error: Missing IP Address in instance config')
}

const url = generateUrl(this.config.ip, this.config.port, cmd, param)

const method = GET.includes(cmd) ? 'get' : POST.includes(cmd) ? 'post' : 'head'
Expand Down

0 comments on commit f00d85d

Please sign in to comment.