-
Notifications
You must be signed in to change notification settings - Fork 10
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
Typed API - Allow calling from the server #130
Comments
For my clarification, you need another part of the server code,
So true! Currently you can import from the API route module and call As a new feature, it is possible for the |
Yes, exactly! Astro pages could also benefit from this. I know that you can probably write the logic there but sometimes code is reused across client and server and caching specific requests like we can do in endpoints its really useful.
Yes, and also It would be super clear — although the |
Implemented basic support in Keeping this open for feedback. |
Nice, that was fast! I'm wondering why a manual call doesn't work and throws an error like I sent you before 🤔 const member = await fetch(
`http://localhost:4321/api/organizations/${organizationId}/members/me/role`,
{
headers: {
"accept": "application/json",
"cookie": ctx.request.headers.get("cookie") ?? "",
},
},
).then((res) => res.json()); |
This call is problematic because the server is calling itself. It could get stuck in a loop if you're not careful. But it should work, what was the error? |
True, it was my mistake. Thanks :) |
Hi there, I was testing the astro-typed-api library and it works great. The only issue I found was that I wanted to reuse an endpoint from an astro action but I get:
I can get a response if I send only the
Accept
header but if I add any other header it throw the error. This is how I'm making the API call from the action:PS: A server client would be nice :)
The text was updated successfully, but these errors were encountered: