Skip to content

Commit 0736ac3

Browse files
committed
improved logging
1 parent 31582e9 commit 0736ac3

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@agility/content-fetch",
3-
"version": "0.5.5",
3+
"version": "0.5.6",
44
"description": "JavaScript library for the Agility Fetch API (node and browser)",
55
"main": "dist/agility-content-fetch.node.js",
66
"scripts": {

src/api-client.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import getPage from './methods/getPage'
88
import FilterOperators from './types/FilterOperator'
99
import FilterLogicOperators from './types/FilterLogicOperator'
1010
import SortDirections from './types/SortDirection'
11+
import { logError } from './utils'
1112

1213
const defaultConfig = {
1314
baseUrl: null,
@@ -66,7 +67,10 @@ export default function createClient(userConfig) {
6667
data['fromCache'] = true;
6768
}
6869
return data;
69-
});
70+
})
71+
.catch(async (error) => {
72+
logError(`AgilityCMS Fetch API ERROR: Request failed for ${reqConfig.baseURL}${reqConfig.url} ... ${error} ... Does the item exist?`)
73+
});
7074
}
7175

7276
//export only these properties:

src/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
function logError(consoleMessage) {
2+
console.error('\x1b[41m%s\x1b[0m', consoleMessage);
3+
}
4+
15
function buildRequestUrlPath(config, languageCode) {
26
let urlPath = null;
37
let apiFetchOrPreview = null;
@@ -64,5 +68,6 @@ export {
6468
buildPathUrl,
6569
buildAuthHeader,
6670
buildRequestUrlPath,
67-
isHttps
71+
isHttps,
72+
logError
6873
}

0 commit comments

Comments
 (0)