Add fococoffee endpoints
This commit is contained in:
16
src/fococoffee/lima.service.ts
Normal file
16
src/fococoffee/lima.service.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ShopifyProduct, parseShopifyProduct } from './shopifyUtils';
|
||||
import axios from 'axios';
|
||||
|
||||
@Injectable()
|
||||
export class LimaService {
|
||||
public readonly shopifyUrl = 'https://www.limacoffeeroasters.com/products.json'
|
||||
|
||||
public async fetchProducts(): Promise<ShopifyProduct<Date>[]> {
|
||||
const response = await axios.get(this.shopifyUrl)
|
||||
if (response.status !== 200) {
|
||||
throw new Error('Failed to fetch products')
|
||||
}
|
||||
return response.data.products.map(parseShopifyProduct);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user