score:0
const maketworequests = async () => {
try{
const firstresponse = await axios.get(first_url);
if(firstresponse.status === 200){
const firstresponsedata = firstresponse.data;
const secondresponse = await axios.get(second_url);
if(secondresponse.status === 200){
const secondresponsedata = secondresponse.data;
}
}
}
catch(error){
console.log(error)
}
}
maketworequests()
firstresponsedata
and secondresponsedata
can be state variables instead of const
for better access throughout the component
Source: stackoverflow.com
Related Query
- Wait for get request response before continuing with a post request in axios
- Can't get headers from Http POST request with Axios
- how do I make a post and get request with ReactJS, Axios and Mailchimp?
- Axios get request response with 403 error forbidden
- How can I make an axios get request wait before rendering my react component
- Axios promise resolving on pre-flight request response which makes associated GET execute out of order with rest of app
- Post Data With Redux and Fetch API with Axios Get Error Result so Looping Response Pending
- Make Multiple Post Requests In Axios then get all the response to make another request
- How to get response headers for 303 request using Axios reactjs
- Waiting for POST request to finish before GET request starts (React/Node)
- get body from axios POST Request with Slim Framework
- React Redux with Redux Observable wait for authentication action to finish before continuing
- How can I wait for an axios post request to be executed inside another axios interceptors?
- Can't get response from axios POST request (React)
- update the state of my component with the response data after Post request with axios
- Wait for axios response before execute code in useEffect
- How to check email overlap using Axios get and post for SignUp with React?
- axios post request with json data
- Making redirects after an axios post request with express
- How to wait for .map() to finish executing before continuing on to next lines of code
- Axios request with chunked response stream from Node
- Missing headers in response for jQuery request with CORS
- react with Rails 5, getting CSRF error for post with axios
- JS unit testing using enzyme: how to wait for setState within component's method to finish before proceeding with test case
- How to have config parameter in axios post request with headers required
- Get axios Response object when error occurred with Redux Saga
- What is the best way to make multiple get request with axios in a loop?
- React and Axios GET request issue with Safari on MacOs and iOs
- Making 2 sequential requests with Axios - second request depends on the response of 1st
- axios get request for real-time data
More Query from same tag
- Problem with use of map function in react for setting text and color of buttons
- why my list have only two items , but it does 20 iterations -REACT
- "ScrollView" like component in React JS?
- Hide title of a Bootstrap NavBar
- Imported image not showing in React
- proper react component usage
- why is typescript complaining when trying to use ref in react?
- Kubernetes secrets passed in to React App container but not being used
- How to change style of child element by root component in material UI?
- React dropdown issue
- React useEffect and useState interaction
- Nested menu using Material UI (4.9.2) - React Js (16.8.5)
- how to get element by component name in ReactJS
- Render buttons as divs to avoid inherited button styles
- React package json loading environment variables
- Iterate through JSON array putting into new array
- JavaScript React JSX: Looping Through Array of Objects And Setting Objects Horizontally Across Web Page
- how to render pdf's dynamically in react?
- Using redux in a React project
- How to place the newline character inside tool tip in react bootstrap?
- Next.js and redux. Populating store on server side does not take effect
- Use nginx to serve static react files a remote server localhost
- Loop through every nested child of React Children
- Spinner is not working with ternary operator
- Add HTTP interceptors under specific routing schema
- How to handle unAuthorized user and redirect it to 403 page in Reactjs
- react render doesn't show anything
- how can I display a list of contacts with name, age, location, and phone props in react? my code does not display anything
- Webpack in React can't load the 3D model with a GLTF extension, shows 404 not found
- How fixed typescript error in custom hook