forked from Yara724/api
logged vehicle usage code
This commit is contained in:
@@ -156,6 +156,10 @@ export class FanavaranLookupService {
|
|||||||
const appToken = await this.getAppToken(profile.auth);
|
const appToken = await this.getAppToken(profile.auth);
|
||||||
const authenticationToken = await this.login(appToken, profile.auth);
|
const authenticationToken = await this.login(appToken, profile.auth);
|
||||||
|
|
||||||
|
this.logger.log(
|
||||||
|
`[${clientKey}] Calling Fanavaran lookup API: ${url}`,
|
||||||
|
);
|
||||||
|
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
this.httpService.get(url, {
|
this.httpService.get(url, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -169,6 +173,34 @@ export class FanavaranLookupService {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const dataCount = Array.isArray(response.data)
|
||||||
|
? response.data.length
|
||||||
|
: typeof response.data === "object" && response.data !== null
|
||||||
|
? Object.keys(response.data).length
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
this.logger.log(
|
||||||
|
`[${clientKey}] Fanavaran lookup response status=${response.status} dataCount=${dataCount}`,
|
||||||
|
);
|
||||||
|
this.logger.log(
|
||||||
|
`[${clientKey}] Fanavaran lookup raw response: ${JSON.stringify(
|
||||||
|
response.data,
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Array.isArray(response.data) && response.data.length > 0) {
|
||||||
|
const firstItem = response.data[0];
|
||||||
|
if (firstItem && typeof firstItem === "object") {
|
||||||
|
this.logger.log(
|
||||||
|
`[${clientKey}] Fanavaran lookup first item keys: ${Object.keys(
|
||||||
|
firstItem,
|
||||||
|
).join(", ")}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = isAxiosError(error)
|
const message = isAxiosError(error)
|
||||||
|
|||||||
Reference in New Issue
Block a user