Fixing the while loop so that 'apiResponse' is correctly over-written. This caused an issue whereby the loop would never end.