# Global function to print the response body

**URL:** <https://community.postman.com/t/global-function-to-print-the-response-body/42997>\
**Category:** Help Hub\
**Tags:** tests, variables, collections\
**Created:** [January 18, 2023, 11:07am UTC](https://community.postman.com/t/global-function-to-print-the-response-body/42997 "2023-01-18T11:07:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avionics-administr10](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@avionics-administr10](https://community.postman.com/u/avionics-administr10)\
**Post date:** [January 18, 2023, 11:07am UTC](https://community.postman.com/t/global-function-to-print-the-response-body/42997/1 "2023-01-18T11:07:01Z")

</div>

hello, I don’t know if I have to post it here, but I couldn’t find an answer and a way to do this.  
I want to create a certain tests for api’s response body and check if it contains a certain value or property. The problem is that I want to create a global function in the collection and in each request to console log the whole response body ONLY if the test fails. I can’t find a proper way to do this and will appreciate if someone helps with this.

---

<div class="post-metadata">

**Author:** ![vmarochok](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vmarochok](https://community.postman.com/u/vmarochok)\
**Post date:** [October 6, 2023, 9:34am UTC](https://community.postman.com/t/global-function-to-print-the-response-body/42997/2 "2023-10-06T09:34:26Z")

</div>

Hi Stefan! I’m looking for something similar for my tests either.  
Have you found the solution?
