Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
SvelteKit externalFetch function in hooks never gets called

I am trying to modify my fetch request for external API to include a custom header. After trying multiple things, I saw externalFetch in the documentation which seems to serve the purpose of modifying the request but the problem is it never gets called. What am I missing?

export async function externalFetch(request) {
    request.headers['authorization'] = 'HMAC 12.33';
    console.log('hook headers', request);
    request = new Request(
        request
    );

    return fetch(request);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to use the fetch function that sveltekit provices you through the load function in order for the externalFetch to trigger, here is an example from the sveltekit documentation:

<!-- src/routes/blog/[slug].svelte -->
<script context="module">
    /** @type {import('@sveltejs/kit').Load} */
    export async function load({ params, fetch, session, stuff }) {
        const response = await fetch(`https://cms.example.com/article/${params.slug}.json`);

    return {
        status: response.status,
        props: {
            article: response.ok && (await response.json())
            }
        };
    }
</script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!