[Vuejs]-VueJS access to a variable from another method

0👍

The error was due to how this works in JS. The function declaration in the promise was creating a different this context than the main function. The function keyword sets this based on where it is called, whereas arrow functions set this based on where it is defined in the code.

All you need to do is replace the function(response){} declaration in the getAPI promise .then with an arrow function, and it will work fine.

makeCall(){
console.log("Requesting Access Token...");
// Using a relative link to access the Voice Token function
getAPI.get("api/contacts/token/")
.then((response) => {

Try replacing these lines – to use an arrow function in the .then

Leave a comment