diff --git a/lib/http-methods/index.js b/lib/http-methods/index.js index 6e5dd34..5923e59 100644 --- a/lib/http-methods/index.js +++ b/lib/http-methods/index.js @@ -3,6 +3,10 @@ require('dotenv').config(); const handleError = err => { if (err.response && err.response.body) { + console.log(`==== line 7`); + console.log(err); + console.log('err.response.body:', err?.response?.body || 'undefined'); + const body = JSON.parse(err.response.body); const error = { status: err.response.statusCode, @@ -63,12 +67,19 @@ const postRequest = async (path, headers, data) => { }; const patchRequest = async (path, headers, data) => { + console.log('=== patchRequest'); + console.log('path:', path || 'undefined'); + console.log('headers:', headers || 'undefined'); + console.log('data:', data || 'undefined'); + try { const response = await got.patch(buildUrl(path), { headers, json: data, }); if (response && response.body) { + console.log(`==== line 81`); + console.log(response.body); return JSON.parse(response.body); } return { status: 'ok' }; @@ -105,7 +116,12 @@ const deleteRequest = async (path, headers) => { }; const buildUrl = (path, searchParams = '') => { + console.log(path); + console.log(searchParams); + const url = process.env.LATITUDE_API_DOMAIN || 'https://api.latitude.sh'; + + console.log(url + path + searchParams); return url + path + searchParams; };