Unverified Commit 7dfb8ec8 authored by Dan Jones's avatar Dan Jones
Browse files

fix: check presence of config

parent 20f10b52
...@@ -68,12 +68,13 @@ class Adapter { ...@@ -68,12 +68,13 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
auth() { auth() {
let config = this.config; let adapterConfig = this.config;
console.error('config', adapterConfig);
return this.axios return this.axios
.get(`${config.api}/token`, { .get(`${adapterConfig.api}/token`, {
params: { params: {
client_id: config.client_id, client_id: adapterConfig.client_id,
secret: config.secret, secret: adapterConfig.secret,
}, },
}) })
.then((response) => { .then((response) => {
...@@ -89,10 +90,10 @@ class Adapter { ...@@ -89,10 +90,10 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
poll() { poll() {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.get(`${config.api}/receive`, { return this.axios.get(`${adapterConfig.api}/receive`, {
headers, headers,
}); });
}) })
...@@ -118,11 +119,11 @@ class Adapter { ...@@ -118,11 +119,11 @@ class Adapter {
* @returns * @returns
*/ */
publish(topic, body) { publish(topic, body) {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${config.api}/send`, `${adapterConfig.api}/send`,
{ {
topic, topic,
body, body,
...@@ -149,11 +150,11 @@ class Adapter { ...@@ -149,11 +150,11 @@ class Adapter {
* @returns * @returns
*/ */
broadcast(body) { broadcast(body) {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${config.api}/notify`, `${adapterConfig.api}/notify`,
{ {
body, body,
}, },
......
...@@ -70,12 +70,13 @@ class Adapter { ...@@ -70,12 +70,13 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
auth() { auth() {
let config = this.config; let adapterConfig = this.config;
console.error('config', adapterConfig);
return this.axios return this.axios
.get(`${config.api}/token`, { .get(`${adapterConfig.api}/token`, {
params: { params: {
client_id: config.client_id, client_id: adapterConfig.client_id,
secret: config.secret, secret: adapterConfig.secret,
}, },
}) })
.then((response) => { .then((response) => {
...@@ -91,10 +92,10 @@ class Adapter { ...@@ -91,10 +92,10 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
poll() { poll() {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.get(`${config.api}/receive`, { return this.axios.get(`${adapterConfig.api}/receive`, {
headers, headers,
}); });
}) })
...@@ -120,11 +121,11 @@ class Adapter { ...@@ -120,11 +121,11 @@ class Adapter {
* @returns * @returns
*/ */
publish(topic, body) { publish(topic, body) {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${config.api}/send`, `${adapterConfig.api}/send`,
{ {
topic, topic,
body, body,
...@@ -151,11 +152,11 @@ class Adapter { ...@@ -151,11 +152,11 @@ class Adapter {
* @returns * @returns
*/ */
broadcast(body) { broadcast(body) {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${config.api}/notify`, `${adapterConfig.api}/notify`,
{ {
body, body,
}, },
......
...@@ -68,12 +68,13 @@ export class Adapter { ...@@ -68,12 +68,13 @@ export class Adapter {
* @returns {object} * @returns {object}
*/ */
auth() { auth() {
let config = this.config; let adapterConfig = this.config;
console.error('config', adapterConfig);
return this.axios return this.axios
.get(`${config.api}/token`, { .get(`${adapterConfig.api}/token`, {
params: { params: {
client_id: config.client_id, client_id: adapterConfig.client_id,
secret: config.secret, secret: adapterConfig.secret,
}, },
}) })
.then((response) => { .then((response) => {
...@@ -89,10 +90,10 @@ export class Adapter { ...@@ -89,10 +90,10 @@ export class Adapter {
* @returns {object} * @returns {object}
*/ */
poll() { poll() {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.get(`${config.api}/receive`, { return this.axios.get(`${adapterConfig.api}/receive`, {
headers, headers,
}); });
}) })
...@@ -118,11 +119,11 @@ export class Adapter { ...@@ -118,11 +119,11 @@ export class Adapter {
* @returns * @returns
*/ */
publish(topic, body) { publish(topic, body) {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${config.api}/send`, `${adapterConfig.api}/send`,
{ {
topic, topic,
body, body,
...@@ -149,11 +150,11 @@ export class Adapter { ...@@ -149,11 +150,11 @@ export class Adapter {
* @returns * @returns
*/ */
broadcast(body) { broadcast(body) {
let config = this.config; let adapterConfig = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${config.api}/notify`, `${adapterConfig.api}/notify`,
{ {
body, body,
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment