karate – how to check the status of id’s captured from response of API call using JS function?

Scenario: I read 20 messages from data.json file and posted them using rest API call. I get UUID within the response which I am storing in postIds array. After I read and post all 20 messages, I need to wait for 3 minutes, like one time where the batchjob job picks up the data and process them and then check the status for each postId. if its passed its success and if its failed the test failed. How do it do it? either my query runs without errors but no proper output or I always get syntax errors.

Background:
    * def oldfirstname = 'abcdef'
    * def oldlastname = 'def'
    * call read('Token.feature')
    * header Authorization = 'Bearer ' + token
    * def config = karate.call('classpath:karate-config.js')
    * def FakerHelper = Java.type('com.API.FakerHelper')
    * def randomFirstName = FakerHelper.getRandomFirstName()
    * def randomLastName = FakerHelper.getRandomLastName()
    * configure retry = { count: 3, interval: 90000 }
    * def Thread = Java.type('java.lang.Thread')
    * def postIds = []

  @post11
  Scenario Outline: Batch Post Messages
    * header Content-Type = 'text/plain'
    * url apiurl
    * def hMessage = data
    * def modifiedmsg = hMessage.replace(oldfirstname, randomFirstName)
    * def modifiedData = modifiedmsg.replace(oldlastname, randomLastName)
    * request modifiedData
    When method POST
    Then status 200
    * def postId = response
    * print postId
    * eval karate.appendTo('postIds', postId)
    * print postIds

    Examples:
      | read('data.json') |

@checkStatus
Scenario: Check status of all messages after 3 minutes
  * def checkStatus =
"""
function(postId) {
  var fullUrl = checkstatusurl + postId;
  var response = karate.get(fullUrl);
  karate.log('Post ID: ' + response. postId + ', Status: ' + response.status);
"""
  * eval Thread.sleep(180000)
  * def storedPostIds = karate.get('postIds')
  * karate.forEach(storedPostIds, checkStatus)