(message: string)
| 48 | } |
| 49 | } |
| 50 | export async function goShopping(message: string) { |
| 51 | const url = 'https://google.serper.dev/shopping'; |
| 52 | const requestOptions: RequestInit = { |
| 53 | method: 'POST', |
| 54 | headers: { |
| 55 | 'X-API-KEY': process.env.SERPER_API as string, |
| 56 | 'Content-Type': 'application/json' |
| 57 | }, |
| 58 | body: JSON.stringify({ "q": message }) |
| 59 | }; |
| 60 | try { |
| 61 | const response = await fetch(url, requestOptions); |
| 62 | if (!response.ok) { |
| 63 | console.error(`Failed to fetch ${url}. Status: ${response.status}`); |
| 64 | } |
| 65 | const responseData = await response.json(); |
| 66 | const shoppingData = { |
| 67 | type: 'shopping', |
| 68 | shopping: responseData.shopping |
| 69 | }; |
| 70 | return JSON.stringify(shoppingData); |
| 71 | } catch (error) { |
| 72 | console.error('Error fetching shopping data:', error); |
| 73 | } |
| 74 | } |
| 75 | export async function getTickers(ticker: string) { |
| 76 | return JSON.stringify({ type: 'ticker', data: ticker }); |
| 77 | } |
nothing calls this directly
no outgoing calls
no test coverage detected