Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to call nuxt server api end points directly without trpc? #5

Open
hafsalm opened this issue Dec 5, 2023 · 1 comment

Comments

@hafsalm
Copy link

hafsalm commented Dec 5, 2023

Is it possible to call nuxt server api endpoints directly without trpc?

image

I was trying to call as follows:

const callAPI = async (index: number) => {
    const data = await useFetch('/api/chats')
    console.info(data)
}

It works in Dev. But when it's built, it gets as following error.

image

My intention is to make a call to a nodejs module inside my application if this works.

Sorry, it's not exactly an issue but rather a general question.
Any hints or guidance you can provide would be greatly appreciated. Thank you

@gurvancampion
Copy link
Owner

@hafsalm You won't be able to use it since Nuxt is running as an SPA and not SSR. Your App bundle is shipped within the electron executable.
Unless I'm missing something, why not use TRPC to call your API directly? Your TRPC server is running inside the main electron process where you can call your node.js module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants