diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/src/useApexREST.js b/src/useApexREST.js index c36444d..04e31b2 100644 --- a/src/useApexREST.js +++ b/src/useApexREST.js @@ -18,14 +18,17 @@ */ function useApexREST(config) { if (!config.auth || !config.endpoint || !config.payload || typeof config.payload !== 'object') { - throw 'useApexREST: invalid configuration object' + return { + apx_status: 'Error', + apx_message: 'useApexREST: invalid configuration object' + } } /** - * `Script.Util.HttpRequest` returns the response in a .NET (?) CLR format. - * This function makes the response usable for JS. - * @returns {object | undefined} - */ + * `Script.Util.HttpRequest` returns the response in a .NET (?) CLR format. + * This function makes the response usable for JS. + * @returns {object | undefined} + */ function processResponse(res) { if (!res || !res.content) { return undefined diff --git a/utils_full.js b/utils_full.js index 0d3dd5c..391ce94 100644 --- a/utils_full.js +++ b/utils_full.js @@ -440,14 +440,17 @@ function sfmcUtils() { */ function useApexREST(config) { if (!config.auth || !config.endpoint || !config.payload || typeof config.payload !== 'object') { - throw 'useApexREST: invalid configuration object' + return { + apx_status: 'Error', + apx_message: 'useApexREST: invalid configuration object' + } } /** - * `Script.Util.HttpRequest` returns the response in a .NET (?) CLR format. - * This function makes the response usable for JS. - * @returns {object | undefined} - */ + * `Script.Util.HttpRequest` returns the response in a .NET (?) CLR format. + * This function makes the response usable for JS. + * @returns {object | undefined} + */ function processResponse(res) { if (!res || !res.content) { return undefined