I want to get data (= user id) after I post How to I store a response data to variable..?
async function start() {
const req = {
'user-num': count,
};
const response = await axios.post(NumURL, { req });
setState(response.data);
// userid(response.data);
console.log(response.data);
// return data
}
I want to get the response data... and the backend api just give json format like {"user-id" : 3}
It means that you are only sending user-id from the backend, however if you can search the user after getting the user id, fetch the data again from the server on the specific endpoint eg:
setState(response.data);
const response = await axios.get(`NumURL/${id}`, { req });
setState(response.user);
just do the get request again on the specific endpoint, after getting the id.