How do i parse Fetch response with superjson

So the issue is that when i fetch data it wraps data into object with key "json" and value of data:
const groupResponse = await fetch(`${baseUrl}/groups`);

//Handle errors
if (!groupResponse.ok) {
throw new TRPCError({
message: "Failed to fetch groups",
code: "BAD_REQUEST",
});
}
const json = await groupResponse.json();
console.log(json);
const groupResponse = await fetch(`${baseUrl}/groups`);

//Handle errors
if (!groupResponse.ok) {
throw new TRPCError({
message: "Failed to fetch groups",
code: "BAD_REQUEST",
});
}
const json = await groupResponse.json();
console.log(json);
And the json variable has a form of
{
json: {some data}
}
{
json: {some data}
}
I could do something weird like:
const json = await groupResonse.json().json
//or
const json = superjson.parse(await groupResponse.json())
const json = await groupResonse.json().json
//or
const json = superjson.parse(await groupResponse.json())
but id love to run into some less cringe solution.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server