Comparing version 0.0.3 to 0.1.0
26
index.js
const fetch = require('node-fetch'); | ||
class Account { | ||
constructor(email, name, created, settings) { | ||
this.email = email; | ||
this.name = name; | ||
this.created = created; | ||
this.settings = settings; | ||
} | ||
} | ||
class Client { | ||
constructor(token) { | ||
constructor(token, url="https://api.omg.lol") { | ||
this.token = token; | ||
this.url = url; | ||
} | ||
async get(url) { | ||
const response = await fetch(url, { | ||
async get(path) { | ||
const response = await fetch(`${this.url}${path}`, { | ||
headers: { | ||
Authorization: `Bearer ${this.token}`, | ||
}, | ||
Authorization: `Bearer ${this.token}` | ||
} | ||
}); | ||
return response.json(); | ||
return await response.json().response; | ||
} | ||
async getAccount() { | ||
const response = await this.get('/account'); | ||
return new Account(response.email, response.name, response.created, response.settings); | ||
} | ||
} | ||
module.exports = Client; |
{ | ||
"name": "omgdotlol", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "API wrapper for omg.lol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1275
28