added undefined debug message to api request function