Leverage 'scripting' in Postman, an example can be seen [here(https://learning.postman.com/docs/writing-scripts/intro-to-scripts/)]