METHOD - 2
**odoo.config.ts**
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class OdooServerConfig {
private ODOO_URL: string;
constructor(private readonly configService: ConfigService) {
this.ODOO_URL = this.configService.get('ODOO_URL');
}
get INTERNAL_TRANSFER(): string {
return this.ODOO_URL + 'data/RawMaterialInternalTransfer';
}
get INVENTORY_SYNC(): string {
return this.ODOO_URL + 'data/InventoryStockData';
}
}
__________________________________________
**inventory.service.ts**
import { HttpService } from '@nestjs/axios';
import { catchError, lastValueFrom, map } from 'rxjs';
export class InventoryService {
constructor(private httpService: HttpService, private readonly odooConfig: OdooServerConfig) {}
async syncInventory() {
const req = this.httpService
.get(this.odooConfig.INVENTORY_SYNC)
.pipe(map((res) => res.data))
.pipe(
catchError((err) => {
return err;
}),
);
const res = await lastValueFrom(req);
console.log(res);
}
}
***app.module.ts***
@Module({
imports: [...],
controllers: [...],
providers: [InventoryService, OdooServerConfig],
})
export class AppModule {}