Sometimes my customer's iPad; iPadOS 14.5 catches 'Unexpected token '<''. Logged in? even if it's operating without problems a few minutes ago. The message confuses me and I want to know where is the problems. They use Native Salesforce app, and call our apps from it.
I make React/Redux on a StaticResources, VF page calls those scripts and it calls Apex class. When reload part of screen, JS catches error "'Unexpected token '<''. Logged in?"
Other pages are displayed without any problem, like Account Page.
I watched an article below, my code doesn't use URLRewriter.
Visualforce Remoting Exception: Error parsing json response: 'Unexpected token <'. Logged in?
here's JS code:
callApi(_serviceName, _methodName, _params, _callback) {
let req = {
service: _serviceName,
method: _methodName,
params: JSON.stringify(_params, replacer),
};
let callback = (_callback && (typeof _callback == 'function')) ? _callback : null;
const remotingOptions = {
buffer: false,
timeout: 120000,
};
return new Promise((resolve, reject) => {
Env.remotingObj.invoke(req, function (response, event) {
try {
if (event.status && response.status === 0) {
// When it's success
let result = TextUtil.unescape(response.result);
if (callback) {
callback(true, result);
}
return resolve(result);
} else {
let message = event.status ? (response || {}).error : event.message;
// here's Unexpected token '<'. Logged in?
if (message.indexOf('Logged in') > 0) {
message = Lang.get('XXXX_MSG_SESSION_TIMEOUT');
}
if (callback) {
callback(false, message);
}
return reject(new Error(message));
}
} catch (e) {
return reject(e);
}
}, remotingOptions);
}
and here's Apex code:
public with sharing class Srv_Place implements Inv_IF {
public Map<String, Object> execute(String methodName, string params) {
Map<String, Object> paramMap = (Map<String, Object>)JSON.deserializeUntyped(params);
if (methodName == 'select') {
return executeSelect(paramMap);
} else {
throw Inv_Exception.createBadMethod(methodName);
}
....
}