Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

421
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda