How to get api response in a Variable?

I am calling an api to authenticate if the user is authenticated or not? Kindly help me in this matter.
var isauth = {
headers: {
method: “GET”,
url: ‘/game/is-authenticated’,
json: true


isauth is returning some object.

You actually need to call the REST API itself via a XHR request.

There are several ways to do this in JS

PlayCanvas has a wrapper for this