I recommend taking a close look at the docs
When setting (saving) objects in the localStorage, the API will always return undefined - you are doing everything all right. Also, it can only store strings, so you first have to serialize your object before storing it. You can use JSON.stringify() for that purpose.
When getting (loading) strings from the localStorage, the API will always return a string or null, so you have to check for null and if a value was loaded parse it back to an object. It you turned the object into JSON, you can use JSON.parse() for that.
Example of using the localStorage: