Edik
Edik
NNuxt
Created by Edik on 9/26/2024 in #❓・help
$fetch inside API
Hello, I try to do a nested fetch. First one is Clientside inside a page $fetch("/api/someApi"), second inside the server in this api inside
defineEventHandler(async (event) => { $fetch("/api/secondApi") })
defineEventHandler(async (event) => { $fetch("/api/secondApi") })
Why the second one doesnt work, and how to make a fetch from API to API?
3 replies
NNuxt
Created by Edik on 8/16/2024 in #❓・help
Plugins - inject Component with Modules
Hello, how to inject a Component from a Module into the application, considering, the possibility, that the Module or Plugin will not be used?
1 replies
NNuxt
Created by Edik on 8/14/2024 in #❓・help
Plugins - inject Component & hook into API Request
Hello, I am trying to make an Application modular. Means it will have default Features, but can also be extended. For this I am looking to modules as "pakets" with multiple plugins which do changes. E.g. There is a form with TextInputs "Name", and "Surname" and an "Submit"-Button. A Module is adding a plugin "advancedForm": /modules/customModule/index.ts:
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'

export default defineNuxtModule({
setup(moduleOptions, nuxt) {
const { resolve } = createResolver(import.meta.url)

addPlugin({
src: resolve('./plugins/advancedForm'),
mode: "client"
})
}
})
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'

export default defineNuxtModule({
setup(moduleOptions, nuxt) {
const { resolve } = createResolver(import.meta.url)

addPlugin({
src: resolve('./plugins/advancedForm'),
mode: "client"
})
}
})
Plugin does Tasks: /modules/customModule/plugins/advancedForm.ts:
export default defineNuxtPlugin((nuxtApp) => {
// Hook into the `page:start` event
nuxtApp.hook('page:start', (pageComponent) => {
// inject component
});
});
export default defineNuxtPlugin((nuxtApp) => {
// Hook into the `page:start` event
nuxtApp.hook('page:start', (pageComponent) => {
// inject component
});
});
Thats how far i got. The Task of the Plugin must do a) add 1 or more components between the textInputs 2) hook into the submit button and api call, so I can manipulate the call and callback The documentation stops at the point "you can do many things with plugins". So sadly I cant find anything related to this. Any help would be appreciated!
1 replies
NNuxt
Created by Edik on 4/26/2024 in #❓・help
Plugins - add third party plugin to Nuxt
Hello, I would like to add fast-json-patch into Nuxt as plugin. I want it to be auto-imported and avaliable globally. I tried to add it in nuxt.config.ts as module, but it doesnt get accepted, because its not an nuxt module I believe. In docs I only find how to create own plugins and add vue-plugins. Any help is appreciated.
9 replies