File tree Expand file tree Collapse file tree 4 files changed +27
-34
lines changed Expand file tree Collapse file tree 4 files changed +27
-34
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @agility/content-fetch" ,
3- "version" : " 0.5.7 " ,
3+ "version" : " 0.5.8 " ,
44 "description" : " JavaScript library for the Agility Fetch API (node and browser)" ,
55 "main" : " dist/agility-content-fetch.node.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import getGallery from './methods/getGallery'
99import FilterOperators from './types/FilterOperator'
1010import FilterLogicOperators from './types/FilterLogicOperator'
1111import SortDirections from './types/SortDirection'
12- import { logError } from './utils'
12+ import { logError , logDebug } from './utils'
1313
1414const defaultConfig = {
1515 baseUrl : null ,
@@ -19,6 +19,7 @@ const defaultConfig = {
1919 languageCode : null ,
2020 headers : { } ,
2121 requiresGuidInHeaders : false ,
22+ debug : false ,
2223 caching : {
2324 maxAge : 0 //caching disabled by default
2425 }
@@ -60,8 +61,14 @@ export default function createClient(userConfig) {
6061
6162 //the function that actually makes ALL our requests
6263 function makeRequest ( reqConfig ) {
63- //make the request using our axios instance
64+
65+ if ( config . debug ) {
66+ logDebug ( `AgilityCMS Fetch API LOG: ${ reqConfig . baseURL } ${ reqConfig . url } ` ) ;
67+ }
68+
69+ //make the request using our axios instance
6470 return api ( reqConfig ) . then ( async ( response ) => {
71+
6572 let data = response . data ;
6673 //if our response is from cache, inject that property in the data response
6774 if ( response . request . fromCache ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ function logError(consoleMessage) {
22 console . error ( '\x1b[41m%s\x1b[0m' , consoleMessage ) ;
33}
44
5+ function logDebug ( consoleMessage ) {
6+ console . log ( '\x1b[33m%s\x1b[0m' , consoleMessage ) ;
7+ }
8+
59function buildRequestUrlPath ( config , languageCode ) {
610 let apiFetchOrPreview = null ;
711
@@ -68,5 +72,6 @@ export {
6872 buildAuthHeader ,
6973 buildRequestUrlPath ,
7074 isHttps ,
71- logError
75+ logError ,
76+ logDebug
7277}
You can’t perform that action at this time.
0 commit comments