How do I handle data from server?


i want to retrieve the data from the server using API I have to check the data has changed in server eg if the new data is added in the server that data should load into my app
i have approach -->
retrieve the data from the server and store into the storage. when the page can load again i can load data from the server but this time i have to check the data is present in the storage if its same I have to return the storage data else save the new data into the storage

                  this.basicDetail = data.basic;
                  console.log('new data comes');
                this.basicDetail = basic;
                console.log('old basic data')}      

tell me any approach to handle new data from the server!