Skip to content

Next JS server Component fetch data when using clerk for authentication and Hono js For backend #4271

Discussion options

You must be logged in to vote

Okay after go through hono RPC guides I get the solution I have to send headers in another object like bellow :

 const response = await client.api.tasks.$get(
        { query: search },
        {
            headers: { Authorization: `Bearer ${token}` },
        },
    );

or I can directly use fetch also

const response = await fetch("http://localhost:3000/api/tasks", {
        method: "GET",
        headers: {
            Authorization: `Bearer ${token}`,
        },
    });

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mehdad-hussain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant