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

151
Vistas
Axios patch doesn't get baseURL

I'm trying to change my Axios patch baseURL but I don't know why when I call this stageReceiver method it still getting a default baseURL (the one where my npm run serve is listening and serving my app).


import axios from "axios";

const getSingleSenders = baseURL =>
  axios
    .get("/single/senders", {baseURL: baseURL})
    .then(({ data }) => ({ senders: data }))

const stageReceiver = (receiverId, baseURL, stagedPayload) =>
  axios
    .patch("/single/receivers/" + receiverId + "/staged", {
        baseURL: baseURL,
        payload: stagedPayload,
        Headers: {"Content-Type": "application/json"}
      })
    .then(({ data }) => ({ receiver: data }))

export default {
    getSingleSenders,
    getSingleSender,
    stageReceiver
};

When I call function when needed with lets say newBaseURL="http://172.17.0.13:8080/test":

const stagedResult = await connectionService.stageReceiver(id, newBaseURL, connectionPayload) 

If I check on the browser I can see that the request is getting 404 with the wrong URL of my Vue dev instance (where my npm run serve is listening):

http://localhost:8082/single/receivers/id/staged

Instead

http://172.17.0.13:8080/test/single/receivers/id/staged

The other method getSingleSenders with get is working without any issue and it get the baseURL correctly written. I'm missing something but I don't know what. I hope the question is clear enough. Many thanks for any advice.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should pass your config as third parameter as stated in the documentation:

const stageReceiver = (receiverId, baseURL, stagedPayload) =>
    axios
      .patch(
         "/single/receivers/" + receiverId + "/staged",
         stagedPayload,
         {
            baseURL: baseURL,
            Headers: { "Content-Type": "application/json" }
         }
      )
      .then(({ data }) => ({ receiver: data }));
about 4 years ago · Juan Pablo Isaza 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