32 lines
		
	
	
		
			831 B
		
	
	
	
		
			TypeScript
		
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			831 B
		
	
	
	
		
			TypeScript
		
	
	
	
import { Injectable } from '@nestjs/common';
 | 
						|
import { ConfigService } from '@nestjs/config';
 | 
						|
import axios from 'axios';
 | 
						|
import { BidsService } from '../services/bids.service';
 | 
						|
 | 
						|
@Injectable()
 | 
						|
export class HotItemApi {
 | 
						|
  constructor(
 | 
						|
    private readonly bidsService: BidsService,
 | 
						|
    private readonly configService: ConfigService,
 | 
						|
  ) {}
 | 
						|
 | 
						|
  listHotItem = async () => {
 | 
						|
    try {
 | 
						|
      const res = await axios({
 | 
						|
        method: 'GET',
 | 
						|
        baseURL: this.configService.get('NEW_ITEM_BASE_URL'),
 | 
						|
        url: '/disti/api/hotitem',
 | 
						|
        headers: {
 | 
						|
          //   ...axios.defaults.headers.common,
 | 
						|
          'Content-Type': 'application/json',
 | 
						|
          Authorization: 'Bearer ' + this.configService.get('NEW_ITEM_TOKEN'),
 | 
						|
        },
 | 
						|
      });
 | 
						|
 | 
						|
      return res.data.data || [];
 | 
						|
    } catch (error) {
 | 
						|
      return [];
 | 
						|
    }
 | 
						|
  };
 | 
						|
}
 |