UNPKG

nuxt-mail

Version:

Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.

21 lines 506 B
import { FetchError } from "ofetch"; import { defineNuxtPlugin } from "#imports"; export default defineNuxtPlugin(() => ({ provide: { mail: { send: async config => { try { await $fetch("/mail/send", { body: config, method: "POST" }); } catch (error) { if (error instanceof FetchError) { throw new TypeError(error.response?._data.statusMessage); } throw error; } } } } }));