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

Eden Treaty: api.get() maps to request GET /ge instead of / #17

Closed
dfalgout opened this issue Sep 11, 2023 · 1 comment
Closed

Eden Treaty: api.get() maps to request GET /ge instead of / #17

dfalgout opened this issue Sep 11, 2023 · 1 comment

Comments

@dfalgout
Copy link

dfalgout commented Sep 11, 2023

Issue:

Hi guys thanks for the great work!

I am running into an issue with eden treaty where the client call api.get() is making the request to /ge instead of /.

Deps:

"dependencies": {
    "@elysiajs/eden": "^0.6.4",
    "@elysiajs/swagger": "^0.6.2",
    "elysia": "latest"
  },
  "devDependencies": {
    "bun-types": "latest"
  },

Code:
Server:

import { Elysia, t } from "elysia";
import { swagger } from "@elysiajs/swagger";

const app = new Elysia()
  .use(swagger())
  .get("/", () => "Hello Elysia")
  .get("/id/:id", ({ params: { id } }) => id)
  .post("/json", ({ body }) => body, {
    body: t.Object({
      name: t.String(),
    }),
    query: t.Object({
      id: t.String(),
    }),
  })
  .listen(3000);

console.log(
  `Elysia running at http://${app.server?.hostname}:${app.server?.port}`
);

export type App = typeof app;

client:

import { edenTreaty } from "@elysiajs/eden";
import type { App } from "./http";

const api = edenTreaty<App>("http://0.0.0.0:3000");
const response = await api.get({});

console.log(response);

result:

{
  data: "NOT_FOUND",
  error: 1 |   status;
2 |   value;
3 |   constructor(e, t) {
4 |
5 |     super(), this.status = e, this.value = t;
  status: 404,
  raw: Response (0 KB) {
    ok: false,
    url: "http://0.0.0.0:3000/ge",
    headers: Headers {
      "content-type": "text/plain;charset=utf-8",
      "date": "Mon, 11 Sep 2023 22:57:21 GMT",
      "content-length": "9"
    },
    statusText: "Not Found",
    redirected: false,
    bodyUsed: true,
    status: 404
  },
  headers: Headers {
    "content-type": "text/plain;charset=utf-8",
    "date": "Mon, 11 Sep 2023 22:57:21 GMT",
    "content-length": "9"
  }
}
@SaltyAom
Copy link
Member

Updating to Eden 0.6.5 should fixed the problem

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