Skip to main content

Global Variables

Global Variables

In the sdk, we have useful global variables to know the environment of our application. You can use them through avt namespace.

avt.platform

  • avt.platform: tells us which device our application is running on, returns "web", "android" or "ios" as appropriate.
  if(platform=='web') {
console.log("Running extension from the web platform!")
}

avt.farms

  • avt.farms: Provides us an array containing every farm of the current user.

It is recommendable not to use this variable. It is much better to use "avt.generalData.getFarms()" from the SDK in it's place.

  avt.generalData.getFarms().forEach((farm) =>{
console.log(farm.nombre)
})

avt.user

  • avt.user: Provides us an object containing the current user's information.

It is recommendable not to use this variable. It is much better to use "avt.generalData.getUserData()" from the SDK in it's place.

const user = avt.generalData.getUserData();
console.log(`Current user's fullname is ${user.datos.nombre} ${user.datos.apellido}`)

token

  • token: provides us with a token in string format, necessary to use the APIs detailed here.

Token variable is the only one that is not accessed through avt namespace.

  fetch("https://api.auravant.com/api/getfields",{
headers:{
Authorization: "Bearer " + token
}
}).then(()=>{
console.log("Using the API with my token")
})