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 {
* @returns {object}
*/
auth() {
let config = this.config;
let adapterConfig = this.config;
console.error('config', adapterConfig);
return this.axios
.get(`${config.api}/token`, {
.get(`${adapterConfig.api}/token`, {
params: {
client_id: config.client_id,
secret: config.secret,
client_id: adapterConfig.client_id,
secret: adapterConfig.secret,
},
})
.then((response) => {
......@@ -89,10 +90,10 @@ class Adapter {
* @returns {object}
*/
poll() {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.get(`${config.api}/receive`, {
return this.axios.get(`${adapterConfig.api}/receive`, {
headers,
});
})
......@@ -118,11 +119,11 @@ class Adapter {
* @returns
*/
publish(topic, body) {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${config.api}/send`,
`${adapterConfig.api}/send`,
{
topic,
body,
......@@ -149,11 +150,11 @@ class Adapter {
* @returns
*/
broadcast(body) {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${config.api}/notify`,
`${adapterConfig.api}/notify`,
{
body,
},
......
......@@ -70,12 +70,13 @@ class Adapter {
* @returns {object}
*/
auth() {
let config = this.config;
let adapterConfig = this.config;
console.error('config', adapterConfig);
return this.axios
.get(`${config.api}/token`, {
.get(`${adapterConfig.api}/token`, {
params: {
client_id: config.client_id,
secret: config.secret,
client_id: adapterConfig.client_id,
secret: adapterConfig.secret,
},
})
.then((response) => {
......@@ -91,10 +92,10 @@ class Adapter {
* @returns {object}
*/
poll() {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.get(`${config.api}/receive`, {
return this.axios.get(`${adapterConfig.api}/receive`, {
headers,
});
})
......@@ -120,11 +121,11 @@ class Adapter {
* @returns
*/
publish(topic, body) {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${config.api}/send`,
`${adapterConfig.api}/send`,
{
topic,
body,
......@@ -151,11 +152,11 @@ class Adapter {
* @returns
*/
broadcast(body) {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${config.api}/notify`,
`${adapterConfig.api}/notify`,
{
body,
},
......
......@@ -68,12 +68,13 @@ export class Adapter {
* @returns {object}
*/
auth() {
let config = this.config;
let adapterConfig = this.config;
console.error('config', adapterConfig);
return this.axios
.get(`${config.api}/token`, {
.get(`${adapterConfig.api}/token`, {
params: {
client_id: config.client_id,
secret: config.secret,
client_id: adapterConfig.client_id,
secret: adapterConfig.secret,
},
})
.then((response) => {
......@@ -89,10 +90,10 @@ export class Adapter {
* @returns {object}
*/
poll() {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.get(`${config.api}/receive`, {
return this.axios.get(`${adapterConfig.api}/receive`, {
headers,
});
})
......@@ -118,11 +119,11 @@ export class Adapter {
* @returns
*/
publish(topic, body) {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${config.api}/send`,
`${adapterConfig.api}/send`,
{
topic,
body,
......@@ -149,11 +150,11 @@ export class Adapter {
* @returns
*/
broadcast(body) {
let config = this.config;
let adapterConfig = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${config.api}/notify`,
`${adapterConfig.api}/notify`,
{
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