push-huawei
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -6,3 +6,2 @@ const axios = require('axios'); | ||
const cache = {}; | ||
class Huawei { | ||
@@ -21,2 +20,3 @@ constructor(options = {}) { | ||
this.options = options; | ||
this.cache = {}; | ||
} | ||
@@ -141,4 +141,4 @@ | ||
async getToken() { | ||
if (cache.access_token && cache.time - new Date().getTime() > 0) { | ||
return { access_token: cache.access_token } | ||
if (this.cache.access_token && this.cache.time - new Date().getTime() > 0) { | ||
return { access_token: this.cache.access_token } | ||
} | ||
@@ -157,4 +157,4 @@ const res = await axios({ | ||
if(res.data.access_token){ | ||
cache.access_token = res.data.access_token; | ||
cache.time = new Date().getTime() + (res.data.expires_in * 1000); | ||
this.cache.access_token = res.data.access_token; | ||
this.cache.time = new Date().getTime() + (res.data.expires_in * 1000); | ||
} | ||
@@ -161,0 +161,0 @@ |
{ | ||
"name": "push-huawei", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "push-huawei", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
7967