how to save last search into data api and delete it after 50 search data saved