+ 2
How access data outside of axios.post in ReactJS?
The response data is not accessable outside the axios request body axios.post(url) .then(res => { //data is accessible here }); //I want to access here
3 ответов
+ 3
You can store data in global variable.
+ 3
Somewhere else in the program, you declare (in the global scope)
var result;
Then, in the.then(), you do:
result = res;
(If you want to store res into result)
+ 1
Idea of global variable doesn't work, I tried a lot