Unverified Commit 20f10b52 authored by Dan Jones's avatar Dan Jones
Browse files

fix: correct use of this in wrong context

parent 33f25858
......@@ -6,8 +6,8 @@ import axios from 'axios';
*/
class Adapter {
constructor(protocol, config) {
this.config = config;
this.protocol = protocol;
this.config = config;
this.axios = axios;
this.validator = new Validator(protocol.schema);
this.auth();
......@@ -68,11 +68,12 @@ class Adapter {
* @returns {object}
*/
auth() {
let config = this.config;
return this.axios
.get(`${this.config.api}/token`, {
.get(`${config.api}/token`, {
params: {
client_id: this.config.client_id,
secret: this.config.secret,
client_id: config.client_id,
secret: config.secret,
},
})
.then((response) => {
......@@ -88,9 +89,10 @@ class Adapter {
* @returns {object}
*/
poll() {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.get(`${this.config.api}/receive`, {
return this.axios.get(`${config.api}/receive`, {
headers,
});
})
......@@ -116,10 +118,11 @@ class Adapter {
* @returns
*/
publish(topic, body) {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${this.config.api}/send`,
`${config.api}/send`,
{
topic,
body,
......@@ -146,10 +149,11 @@ class Adapter {
* @returns
*/
broadcast(body) {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${this.config.api}/notify`,
`${config.api}/notify`,
{
body,
},
......
......@@ -8,8 +8,8 @@ var axios = require('axios');
*/
class Adapter {
constructor(protocol, config) {
this.config = config;
this.protocol = protocol;
this.config = config;
this.axios = axios;
this.validator = new Validator(protocol.schema);
this.auth();
......@@ -70,11 +70,12 @@ class Adapter {
* @returns {object}
*/
auth() {
let config = this.config;
return this.axios
.get(`${this.config.api}/token`, {
.get(`${config.api}/token`, {
params: {
client_id: this.config.client_id,
secret: this.config.secret,
client_id: config.client_id,
secret: config.secret,
},
})
.then((response) => {
......@@ -90,9 +91,10 @@ class Adapter {
* @returns {object}
*/
poll() {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.get(`${this.config.api}/receive`, {
return this.axios.get(`${config.api}/receive`, {
headers,
});
})
......@@ -118,10 +120,11 @@ class Adapter {
* @returns
*/
publish(topic, body) {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${this.config.api}/send`,
`${config.api}/send`,
{
topic,
body,
......@@ -148,10 +151,11 @@ class Adapter {
* @returns
*/
broadcast(body) {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${this.config.api}/notify`,
`${config.api}/notify`,
{
body,
},
......
......@@ -6,8 +6,8 @@ import axios from 'axios';
*/
export class Adapter {
constructor(protocol, config) {
this.config = config;
this.protocol = protocol;
this.config = config;
this.axios = axios;
this.validator = new Validator(protocol.schema);
this.auth();
......@@ -68,11 +68,12 @@ export class Adapter {
* @returns {object}
*/
auth() {
let config = this.config;
return this.axios
.get(`${this.config.api}/token`, {
.get(`${config.api}/token`, {
params: {
client_id: this.config.client_id,
secret: this.config.secret,
client_id: config.client_id,
secret: config.secret,
},
})
.then((response) => {
......@@ -88,9 +89,10 @@ export class Adapter {
* @returns {object}
*/
poll() {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.get(`${this.config.api}/receive`, {
return this.axios.get(`${config.api}/receive`, {
headers,
});
})
......@@ -116,10 +118,11 @@ export class Adapter {
* @returns
*/
publish(topic, body) {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${this.config.api}/send`,
`${config.api}/send`,
{
topic,
body,
......@@ -146,10 +149,11 @@ export class Adapter {
* @returns
*/
broadcast(body) {
let config = this.config;
return this.getAuthorizationHeader()
.then((headers) => {
return this.axios.post(
`${this.config.api}/notify`,
`${config.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