diff --git a/package.json b/package.json index 697348e..e47c4d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@amelix/phoenix.js", - "version": "0.1.5", + "version": "1.0.0", "description": "A feature-rich API wrapper for the critically acclaimed chatting app Phoenix.. or something.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/classes/Client.ts b/src/classes/Client.ts index 55e2b2c..8da36be 100644 --- a/src/classes/Client.ts +++ b/src/classes/Client.ts @@ -76,7 +76,7 @@ export class Client extends EventEmitter { this.invites = new Map() this.user = new ClientUser(this, {}) - this.request("GET", "/users/me").then(res => { + this.request("GET", "/users/me").then(res => { this.user = new ClientUser(this, res.body) this.build() }).catch(e => { @@ -113,7 +113,7 @@ export class Client extends EventEmitter { private connect() { const socketOptions: { [k: string]: any; } = {}; - if (window.location.host === "localhost:3000") socketOptions.query = { token: this.token }; + socketOptions.query = { token: "Bearer " + this.token }; this.socket = io("https://" + hostname, socketOptions); @@ -326,7 +326,7 @@ export class Client extends EventEmitter { async request(method="GET", path:string, headers:{[k: string]: string}={}, write?:any): Promise> { if (typeof write === "object") write = JSON.stringify(write); - headers.authorization = this.token + headers.auth = "Bearer " + this.token return new Promise((resolve, reject) => { const req = https.request({ @@ -347,7 +347,7 @@ export class Client extends EventEmitter { resolve(new PhoenixResponse(res, body)) } else { - reject("An error occurred while connecting to Phoenix...\nServer responded with:\t" + res.statusMessage) + reject("An error occurred while connecting to Phoenix...\nServer responded with:\t" + res.statusCode + " " + res.statusMessage) } }) })