@xsprtd/nuxt-api
Version:
Nuxt API Authentication and Http Client
13 lines (12 loc) • 449 B
JavaScript
import { useApiOptions } from "../composables/useApiOptions.js";
import { useApiFetch } from "../composables/useApiFetch.js";
import extractNestedValue from "../helpers/extractNestedValue.js";
export async function getAuthUser() {
const options = useApiOptions();
const responseKey = options.userResponseKey || null;
const response = await useApiFetch(options.endpoints.user);
return extractNestedValue(
response,
responseKey
);
}