0👍
You can use Axios:
import axios from 'axios';
const apikey = "?api_key=" + "???";
const region = localStorage.getItem("region").toLowerCase() + "1";
const user = "???";
export function makeRequest()
{
return axios.get(
"https://" +
region +
".api.riotgames.com/lol/summoner/v4/summoners/by-name/" +
user + apikey)
.then(response =>
{
return response.data.name;
}).catch(error =>
{
return null;
});
}
Perhaps it would be better if you return the Promise received from the Axios rather than the result of it – in this way you can do whatever you want/need with the Promise, e.g. show some notification when there is an error.
- [Vuejs]-How to go to an URL , search fro an specific class in the boddy and copy its "src"?
- [Vuejs]-Mailtrap error { Expected response code 250 but got code "550", with message "550 5.7.1 Relaying denied " }
Source:stackexchange.com