Update the route that get the report after the call is done. Also added token to the route.
This commit is contained in:
parent
919407eeb1
commit
4f48aef254
18
src/asset.js
18
src/asset.js
@ -86,7 +86,7 @@ class Asset {
|
||||
|
||||
// Here are the asset fields.
|
||||
this.assetProps = bodyObj.data;
|
||||
|
||||
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps)
|
||||
return this._getGroupsFromApi(callback);
|
||||
} else {
|
||||
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||
@ -287,17 +287,21 @@ class Asset {
|
||||
_verifyRecorder(callback) {
|
||||
console.log(chalk.green(`Check to see if a record was created for the unit id: ${this.id} | name: ${this.assetProps.name}`));
|
||||
let startDate = parseInt(this.startTime) - 5000;
|
||||
let stopDate = parseInt(+new Date() + 60 *(1000000 * 60));
|
||||
let stopDate = parseInt(+new Date() + 30 * 1000);
|
||||
setTimeout(() => { this._getRecord(startDate, stopDate); }, 3000);
|
||||
}
|
||||
|
||||
_getRecord(startDate, stopDate) {
|
||||
console.log(this.apiEndpoint + `/history-pagination/1/300/${this.id}/${startDate}/${stopDate}/0/0/0/1`)
|
||||
console.log(this.apiEndpoint + `/history-pagination/1/300/${this.id}/${startDate}/${stopDate}/0/0/0/1/null`)
|
||||
Request.get(
|
||||
this.apiEndpoint + `/history-pagination/1/300/${this.id}/${startDate}/${stopDate}/0/0/0/1`,
|
||||
{},
|
||||
this.apiEndpoint + `/history-pagination/1/300/${this.id}/${startDate}/${stopDate}/0/0/0/1/null`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.token}`
|
||||
}
|
||||
},
|
||||
(error, response, body) => {
|
||||
if (!error && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||
if(!error && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||
let bodyObj = JSON.parse(body);
|
||||
// console.log('bodyObj', bodyObj)
|
||||
if(bodyObj.data.length > 0) {
|
||||
@ -315,7 +319,7 @@ class Asset {
|
||||
console.log(chalk.yellow(`[RECORDER] for asset ${this.id} not found`));
|
||||
}
|
||||
} else {
|
||||
utils.writeLog(`Error getting record for asset ${this.id}`);
|
||||
utils.writeLog(`Error getting record for asset ${this.id} | ${error}`);
|
||||
utils.writeErrorLog(`ERROR_RECORDER`);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user