I have the following code:
const fetcher = (url: string) => axios.get(url).then((r) => r.data);
const {data} = useSWR("api/data", fetcher, {refreshInterval: 10000})
console.log(data.find(d => d.id === "123"))
The API path is as follows:
const promises = matchString.split(",").map(async (match: string) => {
try {
events.push(await Events.find({ name: match }).then((res) => res[0]))
} catch (error) {
events.push(error)
console.log("model/route.js error")
}
})
await Promise.all(promises)
return new Response(JSON.stringify(events), { status: 200 });
However, I encountered the error message:
TypeError: Cannot read properties of undefined (reading 'find')
Could someone please help me with resolving this issue?