Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda