How can I use the data of axios's response outside?
I want a common function like this
function getSrc() {
var src = axios.get('assist/img/src')
.then(function (response) {
return response.data; // the response.data is string of src
})
.catch(function (response) {
console.log(response);
});
// doing other something
return src;
}
but I can't got right value, and I know this is wrong way.
How to do can implement it like this ?
Something need to be supplement.
The reason why I want this is that I don't want function's change affect where call it.
For example, I use jQuery's ajax instead of axios to get something of Server, maybe would be trouble.