As I work on practicing building a simple SPA with VueJS, one of my current tasks involves listening to an API and storing certain data in the browser's localStorage. However, my experience with VueJS is still limited, so I'm unsure about how to extract specific information from the API response and save it in the localStorage for logged-in users to access later.
The API provides a large amount of data, but at this stage, I am only interested in retrieving the user's email and name.
Here is the code snippet I have developed so far:
<script>
import axios from 'axios';
import jsonpAdapter from 'axios-jsonp';
export default {
data() {
return {
info: 'placeH',
data: []
}
},
mounted: function(){
axios({
url: 'APIplaceholder'
adapter: jsonpAdapter
}).then((res) => {
});
}
}
</script>
My current challenge lies in figuring out how to specifically select and extract the required information (email and name) from the overwhelming data provided by the API and then store it in the localStorage.
I believe that saving this extracted information in a JSON file within the localStorage would be the most efficient approach.