Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
Nuxt 3 server router does not response

I have followed the documentation of "Advanced usage" https://v3.nuxtjs.org/guide/features/server-routes#advanced-usage-examples

Now i tried it out:

My folder is structured like this:

server\api\global.ts

Here is my file global.ts

import { createRouter } from "h3";

const router = createRouter();

router.get("/", () => "Hello World");

export default router;

Now i try to fetch some data:

export const Bloggy = {
  login({ password, username }: LoginParameterI) {
    return $fetch("/api/global", {
      method: "GET",
    });
  },
};

interface LoginParameterI {
  password: string;
  username: string;
}

Now when i try to fetch some data, i receive an error:

[nuxt] [request error] Invalid lazy handler result. It should be a function

I wanted to use it with router, because i want to use certain middlewares for certain routes. In the nuxt documentation the middlewares will get triggered on every route

What am i doing wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!