Triggering an http call to an API based on a msg property value in the msg.payload from a previous node

Hello people,
I am making an http request (using http request node) to an API and I get the output in msg.payload as a JSON object. Based on the value of a particular key within this JSON object, I want to trigger another http request (POSY/DEL/GET). Also, in order to make a POST/DEL request, I have to input some parameters to be able to make a request. I normally do this by writing the parameters in the script. However, how do I trigger the http request with the condition that if the particular msg property has a specific value make a http request with certain parameters?

First feed the JSON string into a JSON node to convert it to a javascript object.

Then you can use a Switch node to send the message down different paths dependent on the value of the property, then in the appropriate path you can set the parameters accordingly.
Or if you are happy writing javascript then you don't need the switch, you can just test the property and set the parameters.

Hi Colin,
Thank you.
That was pretty straight forward, I was trying to write the script and hence faced an issue but now it is solved.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.