I'm creating a new little project in Google Spreadsheets to get some data from Playfab servers for a game in Kongregate. Playfab provides a Javascript API to work:
https://download.playfab.com/PlayFabClientApi.js
I will use the function
But when I try to run my first test I get the error message:
ReferenceError:"Promise" no está definido.(línea 33, archivo "Código")
After some research I readed that Promise is not supported by GAS (Google Apps Script), but somewhere I readed V8 could use promises... I'm little lost, could you help me a little to make this work?
I have this question in stackoverflow:
My code in my project:
// Load JavaScript from External Servervar url ="https://download.playfab.com/PlayFabClientApi.js";var javascript =UrlFetchApp.fetch(url).getContentText();var token ="1111111111111111111111111111111111111111111111111111111111111111";var kongID ="1111111";eval(javascript);/* ######################################################################## *//* ######################## MENU FUNCTION ################################# *//* ######################################################################## */function onOpen(){var menu =SpreadsheetApp.getUi().createMenu('PLAYFAB MENU'); menu.addItem('FirstCallPlayfab','PlayFabAPICall').addToUi();}functionPlayFabAPICall(){PlayFab.settings.titleId ="E3FA";var loginRequest ={// Currently, you need to look up the correct format for this object in the API-docs:// https://api.playfab.com/documentation/Client/method/LoginWithCustomIDTitleId:PlayFab.settings.titleId,AuthTicket: token,CreateAccount:false,KongregateId: kongID,};PlayFabClientSDK.LoginWithKongregate(loginRequest,LoginCallback);}varLoginCallback=function(result, error){if(result !==null){Logger.log("Congratulations, you made your first successful API call!");}elseif(error !==null){Logger.log("Something went wrong with your first API call.\n"+"Here's some debug information:\n"+PlayFab.GenerateErrorReport(error));}}
The function LoginWithKongregate in the API file:
LoginWithKongregate:function(request, callback, customData, extraHeaders){ request.TitleId=PlayFab.settings.titleId ?PlayFab.settings.titleId : request.TitleId;if(!request.TitleId)throwPlayFab._internalSettings.errorTitleId;// PlayFab._internalSettings.authenticationContext can be modified by other asynchronous login attempts// Deep-copy the authenticationContext here to safely update itvar authenticationContext = JSON.parse(JSON.stringify(PlayFab._internalSettings.authenticationContext));var overloadCallback =function(result, error){if(result !=null){if(result.data.SessionTicket!=null){PlayFab._internalSettings.sessionTicket = result.data.SessionTicket;}if(result.data.EntityToken!=null){PlayFab._internalSettings.entityToken = result.data.EntityToken.EntityToken;}// Apply the updates for the AuthenticationContext returned to the client authenticationContext =PlayFab._internalSettings.UpdateAuthenticationContext(authenticationContext, result);PlayFab.ClientApi._MultiStepClientLogin(result.data.SettingsForUser.NeedsAttribution);}if(callback !=null&&typeof(callback)==="function") callback(result, error);};