nuxt-logsnag
Version:
Simple LogSnag integration for Nuxt 3
25 lines (24 loc) • 584 B
JavaScript
import { useNuxtApp, useRuntimeConfig } from "#imports";
const endpoint = "https://api.logsnag.com/v1/log";
export const useLogSnag = () => {
const nuxt = useNuxtApp();
const config = useRuntimeConfig();
const publish = async (data) => {
try {
return await $fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${config.logsnag.token}`
},
body: data
});
} catch (err) {
console.error(err);
throw err;
}
};
return {
publish
};
};