19 lines
362 B
JavaScript
19 lines
362 B
JavaScript
export default class Storage {
|
|
constructor() {
|
|
this.prefix = "notesapp"
|
|
}
|
|
|
|
getNotes() {
|
|
const notesString = localStorage.getItem(`${this.prefix}-notes`)
|
|
if (notesString) {
|
|
return JSON.parse(notesString)
|
|
} else {
|
|
return []
|
|
}
|
|
}
|
|
|
|
saveNotes(notes) {
|
|
console.log(notes)
|
|
localStorage.setItem(`${this.prefix}-notes`, JSON.stringify(notes))
|
|
}
|
|
} |