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

419
Views
Sveltekit POST method not allowed on endpoint

I am trying to get this fetch method to work in Svelte

When the page.svelte calls the function to fetch the data, in the console I receive this

[HTTP/1.1 405 Method Not Allowed 19ms]

Which I have narrowed down to this

POST method not allowed

Is there a variable I need to set in the config files or is there another solution which I am missing?

// svelte.config.js

import adapter from '@sveltejs/adapter-auto';

const config = {
    kit: {
        adapter: adapter(),
        methodOverride: {
            allowed: ['POST']
        },
    }
};

export default config;

Both files are in the Routes folder

// fetch-data.js

export const POST = async(data) => {
  const response = // get data function here
  return {
    body: {
        data: response
    }
  }
}

// page.svelte

async function fetchData() {
   const response = await fetch('./fetch-data', {
     method: 'POST',
     body: JSON.stringify(),
     headers: {
       'content-type': 'application/json'
     }
   })
   const { data } = await response.json()
   return data
}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The solution was to change the POST variable name to lowercase in the get-data.js file

about 4 years ago · Santiago Trujillo 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!