Objectives:
Examples:
/users
: a collection of users/users/1
: a single user/users/1/posts
: blog posts belonging to a particular userSchema (blog post):
localStorage
and sessionStorage
sessionStorage
lets you store data on the client for a single session (until the browser or tab is closed)localStorage
lets you store data on the client that persists until explicitly deleted.protocol
or scheme, the hostname
and port
.
https://example.com
https://example.com/sales/
and https://example.com/products
share the same originhttps://sales.example.com
localStorage.getItem(item)
to retrieve an item from storage. Returns null if the item does not existlocalStorage.setItem(item, value)
to store an item in storagelocalStorage
can only store strings (both keys and values)localStorage
can only store string objectsJSON.stringify(obj)
: converts an object to a string representation in JSON formatJSON.parse(JSON_string)
: converts a JSON object into a javascript objectYou can store it like so:
You can retrieve it like so: