mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
fixes
This commit is contained in:
@@ -3,13 +3,15 @@ require('request-debug')(request);
|
||||
const retrieveApp = require('./retrieve-app');
|
||||
|
||||
function hooks(logger, callInfo) {
|
||||
function actionHook(hook, obj, expectResponse = true) {
|
||||
logger.debug({callInfo}, 'creating action hook');
|
||||
function actionHook(hook, obj = {}, expectResponse = true) {
|
||||
const method = hook.method.toUpperCase();
|
||||
const auth = (hook.username && hook.password) ?
|
||||
{username: hook.username, password: hook.password} :
|
||||
null;
|
||||
|
||||
const data = Object.assign({}, obj, callInfo);
|
||||
logger.debug({data}, `actionhook sending to ${hook.url}`);
|
||||
if ('GET' === method) {
|
||||
// remove customer data - only for POSTs since it might be quite complex
|
||||
delete data.customerData;
|
||||
@@ -20,8 +22,8 @@ function hooks(logger, callInfo) {
|
||||
json: 'POST' === method || expectResponse
|
||||
};
|
||||
if (auth) obj.auth = auth;
|
||||
if ('POST' === method) obj.body = data;
|
||||
else obj.qs = data;
|
||||
if ('POST' === method) opts.body = data;
|
||||
else opts.qs = data;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request(opts, (err, response, body) => {
|
||||
|
||||
Reference in New Issue
Block a user