Hi Nitesh,
This should be possible using Virtual Endpoints. You can do this by essentially capturing the response from a request to the first endpoint and using the body of said response to write the body of a request to the second endpoint. Below is an example of the code you could write:
var requestOne = {
"Method": "GET",
"Body": "",
"Headers": {},
"Domain": "http://foo.com",
"Resource": "/widgets/1234",
"FormData": {}
};
var responseOne = TykMakeHttpRequest(JSON.stringify(requestOne))
var requestTwo = {
"Method": "POST",
"Body": responseOne.Body,
"Headers": responseOne.Headers,
"Domain": "http://foo.com",
"Resource": "/widgets/follow-on/",
};
var responseTwo = TykMakeHttpRequest(JSON.stringify(requestTwo))
var usableResponse = JSON.parse(responseTwo);
var responseObject = {
Body: "THIS IS THE VIRTUAL RESPONSE"
Headers: responseTwo.Headers,
Code: responseTwo.Code
}
return TykJsResponse(responseObject, session.meta_data)
Hope that helps.
Kind regards,
Jess @ Tyk