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
16
src/asset.js
16
src/asset.js
@ -86,7 +86,7 @@ class Asset {
|
|||||||
|
|
||||||
// Here are the asset fields.
|
// Here are the asset fields.
|
||||||
this.assetProps = bodyObj.data;
|
this.assetProps = bodyObj.data;
|
||||||
|
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps)
|
||||||
return this._getGroupsFromApi(callback);
|
return this._getGroupsFromApi(callback);
|
||||||
} else {
|
} else {
|
||||||
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||||
@ -287,15 +287,19 @@ class Asset {
|
|||||||
_verifyRecorder(callback) {
|
_verifyRecorder(callback) {
|
||||||
console.log(chalk.green(`Check to see if a record was created for the unit id: ${this.id} | name: ${this.assetProps.name}`));
|
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 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);
|
setTimeout(() => { this._getRecord(startDate, stopDate); }, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getRecord(startDate, stopDate) {
|
_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(
|
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) => {
|
(error, response, body) => {
|
||||||
if(!error && (response.statusCode === 200 || response.statusCode === 201)) {
|
if(!error && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||||
let bodyObj = JSON.parse(body);
|
let bodyObj = JSON.parse(body);
|
||||||
@ -315,7 +319,7 @@ class Asset {
|
|||||||
console.log(chalk.yellow(`[RECORDER] for asset ${this.id} not found`));
|
console.log(chalk.yellow(`[RECORDER] for asset ${this.id} not found`));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
utils.writeLog(`Error getting record for asset ${this.id}`);
|
utils.writeLog(`Error getting record for asset ${this.id} | ${error}`);
|
||||||
utils.writeErrorLog(`ERROR_RECORDER`);
|
utils.writeErrorLog(`ERROR_RECORDER`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user