Get the variable of a json request outside the function