Skip to content

Commit

Permalink
Made everything actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
Amelixx committed Jan 11, 2022
1 parent ed3b374 commit 1caa008
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/classes/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Client extends EventEmitter {
this.invites = new Map()

this.user = new ClientUser(this, {})
this.request<ClientUser>("GET", "/users/me").then(res => {
this.request("GET", "/users/me").then(res => {
this.user = new ClientUser(this, res.body)
this.build()
}).catch(e => {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -326,7 +326,7 @@ export class Client extends EventEmitter {
async request<T=any>(method="GET", path:string, headers:{[k: string]: string}={}, write?:any): Promise<PhoenixResponse<T>> {
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({
Expand All @@ -347,7 +347,7 @@ export class Client extends EventEmitter {
resolve(new PhoenixResponse<T>(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)
}
})
})
Expand Down

0 comments on commit 1caa008

Please sign in to comment.