Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1611,16 +1611,19 @@
if (!data.error && !data.status_code) {
console.warn('No error param in registerFetchError data', data);
} else if (data.error) {
// Convert runtime `error` to `error_code` and `error_message`.
if (typeof data.error === 'string') {
fetch_data.error_code = data.error
} else {
// Convert runtime `error` to `error_code` and `error_message`.
if (data.error.code) {
fetch_data.error_code = data.error.code;
}
if (data.error.message) {
fetch_data.error_message = data.error.message;
}
if (data.error.name) {
fetch_data.error_code = data.error.name;
}
if (!data.error.code && !data.error.message) {
fetch_data.error_message = '' + data.error;
}
Expand Down
12 changes: 6 additions & 6 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function(options, iframely_options, callback) {

var prefix = CONFIG.API_REQUEST_CACHE_PREFIX ? (CONFIG.API_REQUEST_CACHE_PREFIX + ':') : '';

var lang = iframely_options.getProviderOptions('locale');
var lang = iframely_options?.getProviderOptions('locale');
if (lang) {
prefix += lang + ':';
}
Expand All @@ -94,13 +94,13 @@ export default function(options, iframely_options, callback) {
}

if (error) {
iframely_options.registerFetchError({
iframely_options?.registerFetchError({
source: 'api',
url: options.uri,
error: error
});
} else if (result && result.status !== 200) {
iframely_options.registerFetchError({
iframely_options?.registerFetchError({
source: 'api',
url: options.uri,
status_code: result.status
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function(options, iframely_options, callback) {
});
}

iframely_options.registerFetch({
iframely_options?.registerFetch({
source: 'api',
url: options.uri
});
Expand All @@ -171,7 +171,7 @@ export default function(options, iframely_options, callback) {
}

// Ignore proxy.cache_ttl, if options.cache_ttl === 0 - do not read from cache.
if (iframely_options.cache_ttl === 0) {
if (iframely_options?.cache_ttl === 0) {

if (useCacheOnly) {

Expand All @@ -197,7 +197,7 @@ export default function(options, iframely_options, callback) {
}
}

iframely_options.registerFetch({
iframely_options?.registerFetch({
source: 'cache',
url: options.uri
});
Expand Down
Loading