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
Describe the issue
When calling retrieveRecordedRequestsAndResponses and trying to out the result from the promise, the data remains unchanged, due to inverted execution code ( classic promise issue ).
What you are trying to do
Trying to out the result from the promise...
MockServer version
5.15.0
To Reproduce
try this code :
let records: HttpRequestAndHttpResponse[] = [];
await mockServerClient("localhost", 1080)
.retrieveRecordedRequestsAndResponses({})
.then((rs: HttpRequestAndHttpResponse[]) => {
console.log('Inside, my data are there : ' + JSON.stringify(rs));
records = rs;
});
console.log('Outside, my data array is empty :-( ' + JSON.stringify(records));
How you are running MockServer (i.e maven plugin, docker, etc)
in an express instance (but not related to the bug)
Code you used to create expectations
there is no expectations, only recording requests and trying to get them after
What error you saw
no error ( but .catch does related to the missing return )
Expected behaviour
The recordedRequestAndResponses behaves as the others functions, regarding promise execution. Then the result to be passed outside the promise of my call.
** Fix proposed **
Simply add return into retrieveRecordedRequestsAndResponses for the makeRequest call, as the other functions have.
var retrieveRecordedRequestsAndResponses = function (pathOrRequestMatcher) {
return {
then: function (sucess, error) {
return makeRequest(host, port, "/mockserver/retrieve?type=REQUEST_RESPONSES&format=JSON", addDefaultRequestMatcherHeaders(pathOrRequestMatcher))
.then(function (result) {
sucess(result.body && JSON.parse(result.body));
}, function (err) {
error(err);
});
}
};
};```
Thank you
The text was updated successfully, but these errors were encountered:
Describe the issue
When calling retrieveRecordedRequestsAndResponses and trying to out the result from the promise, the data remains unchanged, due to inverted execution code ( classic promise issue ).
What you are trying to do
Trying to out the result from the promise...
MockServer version
5.15.0
To Reproduce
try this code :
in an express instance (but not related to the bug)
there is no expectations, only recording requests and trying to get them after
no error ( but .catch does related to the missing return )
Expected behaviour
The recordedRequestAndResponses behaves as the others functions, regarding promise execution. Then the result to be passed outside the promise of my call.
** Fix proposed **
Simply add
return
intoretrieveRecordedRequestsAndResponses
for themakeRequest
call, as the other functions have.The text was updated successfully, but these errors were encountered: