0

I would appreciate your assistance if possible , I wrote a javascript code that calculates a Fibonacci nth term, how Can I use it in Postman. I send an initial request to an endpoint and the response sends back data (a n term for example: 43) I would like to then use this received data(43) in my code to the calculate the answer and send back a post with the answer calculated from my code. P.S Im new with API etc

  • create a node server and there end-point for access. put the code on controller page and than access that controller with postman. – Abhishek Feb 06 '20 at 12:41

1 Answers1

0

You have to place your java script code in the “Test” tab of the request. Refer this page more info: https://learning.postman.com/docs/postman/scripts/intro-to-scripts/

  1. Use pm.response.json() to get the value (ex., 43 in your case)
  2. Use your fibonacci function to calculate the output.
  3. Save the ouput to the environment using pm.environment.set()
  4. Create a new request and get the value from the environments and use it further.
Jeeva
  • 438
  • 4
  • 12