Need help in ReactJS useState value getting null/undefined outside the axios response .
Budget: ₹600 – ₹1,500 INR
useState first time value getting null . i.e -
pagename -- config.js & code below ---
import { useEffect, useState } from "react";
import axios from "axios";
const[uid, setUid] = useState("");
axios.get('https://reqres.in/api/users/1').then(res=>{
setUid(res.data.id) //suppose here is id value set
})
// I want uid value here to export
export const userid = { id: uid }; //here uid getting null value first time .
pagename -- config.js & code below ---
import { useEffect, useState } from "react";
import axios from "axios";
const[uid, setUid] = useState("");
axios.get('https://reqres.in/api/users/1').then(res=>{
setUid(res.data.id) //suppose here is id value set
})
// I want uid value here to export
export const userid = { id: uid }; //here uid getting null value first time .