Skip to content
Advertisement

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 something

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 Code of the Component

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 asynchronous call that returns a promise, that statement doesn’t

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

Axios instance not working with Nextjs: ‘Localstorage not defined’

I have a react app. I have an axios component I want to reuse: Now, I try and import this into my registration page as follows: import axiosInstance from “axiosInstance” The file itself looks like this: However, this throws an error: Can some please help me with this issue? I am new to Nextjs and looked at https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr but not

TypeError: this.state.data.map in reactjs

Hii All , I know this question is asked many times but I cant figure it out I’am getting the error. I have checked for all the questions similar to this but haven’t found specific solution if I use another link i.e, “https://jsonplaceholder.typicode.com/users” this one the code works fine . Answer The returned data from https://reqres.in/api/users?page=2 is not an array,

Javascript dictionary keys not updating within an axios request

I currently have the following code in my app: Where getUserData and getTestData interact w/ my external API. The getTestData endpoint returns something like {success: True/False, json: {String key: {time: UNIX time, value: float}}} After running this, I would thus expect testData to look like {CM10: [{x: time, y: value}]} for each value and time received in the API call.

Advertisement