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

150
Views
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 answers
Answer question

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 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!