Skip to content

How to get response headers? #151

Answered by jycouet
revnelson asked this question in Q&A
Discussion options

You must be logged in to vote

Check out the Announcement here


Now you can hook up before or after the fetch,

Here is an example 👇

import type { RequestHandlerArgs } from '$houdini';
import { HoudiniClient } from '$houdini';
import { stry } from '@kitql/helper';

// For Query & Mutation
async function fetchQuery({
  fetch,
  text = '',
  variables = {},
  session,
  metadata
}: RequestHandlerArgs) {
  // Prepare the request
  const url = import.meta.env.VITE_GRAPHQL_ENDPOINT || 'http://localhost:4000/graphql';

  // regular fetch (Server & Client)
  const result = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${session?.token}` // session u…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jycouet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants