Lambda function does not invoke properly when the deployed lambda URL gets hit

I am working on an Iot project. Here, I am using AWS Iotcore that is receiving data from Iot device and by a lambda function triggering that data to Dynamodb. I have used cloudformation for deploying the lambda functions in order to fetching last 10 hours data. The device is continuously running and its emitting data to iotcore after every 20 seconds. I want the latest 5 hours data when i hit the URL.  I have used serverless framework. When I run it locally works fine, but it does not provide current data from deploying URL. The deployed API updates data after certain times(after 1.5 or 2 hours). I don't get the recent data when I hit the URL. I have seen the cloud watch logs of lambda invocations. When I hit the API, it actually not invoking lambda. It only invokes after certain time period as I mentioned. How can I resolve this issue?