You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.warn('[warning] add_fn is deprecated, use get/post/all instead');
84
84
}
85
+
86
+
if(req.method==='POST'&&!req.body){
87
+
thrownewError('YemotRouter: it look you use api_url_post=yes, but you didn\'t include express.urlencoded({ extended: true }) middleware! (https://expressjs.com/en/4x/api.html#express.urlencoded)');
returnres.json({message: 'request is not valid yemot request'});
88
94
}
89
95
90
-
req.query=shiftDuplicatedFromQuery(req.query);
96
+
if(req.method==='POST'){
97
+
req.body=shiftDuplicatedValues(req.body);
98
+
}else{
99
+
req.query=shiftDuplicatedValues(req.query);
100
+
}
91
101
92
-
constcallId=req.query.ApiCallId;
102
+
constcallId=values.ApiCallId;
93
103
94
104
letisNewCall=false;
95
105
letcurrentCall=activeCalls[callId];
96
106
if(!currentCall){
97
107
isNewCall=true;
98
-
if(req.query.hangup==='yes'){
108
+
if(values.hangup==='yes'){
99
109
logger(callId,'👋 call is hangup (outside the function)');
100
110
returnres.json({message: 'hangup'});
101
111
}
102
112
currentCall=newCall(callId,eventsEmitter,ops);
103
113
activeCalls[callId]=currentCall;
104
-
logger(callId,`📞 new call - from ${req.query.ApiPhone}`);
114
+
logger(callId,`📞 new call - from ${values.ApiPhone}`);
105
115
}
106
116
107
117
currentCall.setReqValues(req,res);
108
118
119
+
if(req.method==='POST'){
120
+
const_query=req.query;
121
+
constproxy=newProxy(_query,{
122
+
get: function(target,propName){
123
+
console.warn(`[${req.path}] You are trying to access the '${propName}' property on the request query string object, but you have set the 'api_url_post=yes' option. This means that the yemot values will be in the request body object, not the request query object.\nPlease update your code accordingly - instead of call.req.query.propName, use call.req.body.propName.`);
124
+
returntarget[propName];
125
+
}
126
+
});
127
+
req.query=proxy;
128
+
currentCall.query=proxy;
129
+
}else{
130
+
const_body=req.body;
131
+
constproxy=newProxy(_body,{
132
+
get: function(target,propName){
133
+
if(!target[propName])console.warn(`[${req.path}] If you do not use the api_url_post=yes option, the values will be in the call.req.query object, not the call.req.body object.\nPlease update your code accordingly - instead of call.req.body.propName, use call.req.query.propName, or use the api_url_post=yes option.`);
0 commit comments