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
};

console.log("auth"+isauth);

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 https://developer.playcanvas.com/en/api/pc.Http.html