Skip to content

Tag: axios

Problem with dynamic request header in axios template

In my react app, I created an api.js file which creates an api object with axios.create and exports it as default. So, I use that template to make the API requests. The problem is that, one of the headers in created axios api object must be dynamic. For example, see the locale header below: At first it may be…

Axios Undefined Response

I am Developing MERN Stack Project. The problem is when I make the first API Call the first response is undefined and the map function gives an error ‘Map is not a function and it makes sense. the problem is i tried several approaches to prevent this from happening but it won’t work This is the Co…

How to get catch error 404 error in Axios?

I have this snippet of code (part of a function), notice the “BadURL” at the end of the URL: import axios from “axios”; But canno’t get into the catch block, says: I can catch the error only if i wrap the function call itself outside the class Answer Axios.post(…) is an asy…

How to pass variable in URL React js

in react js I made a simple date picker and select date from the dropdown calendar and I displayed it in the console. that date stored in a variable, now how to use that variable in URL My questions : How to pass parameter in React js URL how to print parameter in console log code: A date is from