nksaraf / vinxi

The Full Stack JavaScript SDK
https://vinxi.vercel.app
MIT License
1.33k stars 57 forks source link

server functions: allow get requests #303

Closed OrJDev closed 2 weeks ago

OrJDev commented 1 month ago
    const get1 = async () => {
        const res = await fetch("http://localhost:3000/_server", {
            method: "GET",
            headers: {
                "Server-Action":
                    "/Users/or/Desktop/vinxi/examples/solid/ssr/basic/app/getActions.tsx#getAction",
            },
        });
        const data = await res.json();
        console.log(data);
    };

this is now valid, i was also trying to make this valid:


    const get2 = async () => {
        const res = await fetch(
            `http://localhost:3000/_server?serveract=${encodeURIComponent(
                "/Users/or/Desktop/vinxi/examples/solid/ssr/basic/app/getActions.tsx#getAction",
            )}`,
            {
                method: "GET",
            },
        );
        const data = await res.json();
        console.log(data);
    };

but the codebase was so messy and untyped i barely could have got anything moving. this is useful for an open graph library we are building as a part of solid mediakit.

i'm aware that params don't exist when making a get request and that is fine we don't need this rn, we just need the base working.

codesandbox[bot] commented 1 month ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 0d6b09b5919c79a5c5fccefd6a5ba8ace3f1f0c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages | Name | Type | | ------------------------------------- | ----- | | @vinxi/server-functions | Patch | | vinxi | Patch | | @vinxi/react-server | Patch | | react-rsc-spa | Patch | | react-rsc-ssr | Patch | | solid-ssr-basic | Patch | | example-vanilla-spa | Patch | | example-vanilla-stack | Patch | | test-react-rsc | Patch | | test-react-srv-fn | Patch | | test-react-to-web-request | Patch | | @vinxi/router | Patch | | example-react-server | Patch | | example-react-spa-basic | Patch | | react-spa-mdx | Patch | | react-spa-tanstack-router-app | Patch | | example-react-spa-tanstack-router-app | Patch | | react-ssr-basic-cloudflare | Patch | | react-ssr-basic | Patch | | react-ssr-tanstack-router-app | Patch | | react-ssr-wouter | Patch | | solid-spa-basic | Patch | | example-ssr-solid-router | Patch | | example-vanilla-empty | Patch | | example-vanilla-partyroom | Patch | | example-vanilla-server | Patch | | example-vanilla-trpc | Patch | | test-multi-spa | Patch | | react-ssr-test-fs | Patch | | test-react | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 1 month ago

@OrJDev is attempting to deploy a commit to the Nikhil Saraf's projects Team on Vercel.

A member of the Team first needs to authorize it.

Brendonovich commented 3 weeks ago

@OrJDev Start's server functions can already be called with GET, solid-router does it. image

From what I can tell vinxi-server-functions/server-handler.js isn't actually used by Start, it supplies its own.

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vinxi-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 7:17pm