Call a server utilities in Nuxt3

Viewed 34

In my Nuxt3 app, I am trying to ask the server to send an email.

I know how to call an api through server/api but I can't deal with server utilities.

My server utility is defined as follows, in /server/utils/mail/send.ts:

export default defineEventHandler(() => 'You try to send an email !');

I try to call it in a component as follow:

console.log(await useFetch('/utils/mail/send'));

But the route seems to not be known from the server, I get the error: 'GET http://localhost:3000/utils/mail/send 404 (Page not found: /utils/mail/send)' in the browser console, and this one in the server console: '[Vue Router warn]: No match found for location with path "/utils/mail/send"'

Can someone explain to me how to use server utilities ? The nuxt documentation redirect to unjs/h3 documentation but it is not very clear.

0 Answers
Related