Hey guys! What’s up?
I’m building my app, most of it will be native, making calls to a PHP backend and building the interface with fuse.
In some pages, like “My Account”, for now I would like to use the WebView and load a web page into it, but I have to specify a cookie/session token when making the GET request, so my webserver knows what user is requesting the information, in order to deliver the right data.
I already have this token in a SessionHandler variable, and I use it to make all API request, like this:
fetch("https://api.mydomain.com/getInternalMenuItens", {
method: 'GET',
headers: {
"Cookie": "UserToken="+ _SessionHandler.token
}
})
.then(function(result) {
if (result.status !== 200) {
debug_log("Something went wrong, status code: " + result.status);
errorMessage.value = "Oh noes! :(";
return;
}
return result.json();
})
.then(function(data) {
_InternalMenu.replaceAll(data);
})
.catch(function(error) {
debug_log("Fetch error " + error);
errorMessage.value = "Oh noes! :(";
});
My question: Is it possible to send this token in the header request of WebView request?
Or build an iframe or something?
Thanks!