#Localstorage does not return any object

27 messages · Page 1 of 1 (latest)

lilac wadi
#

I am building a sveltekit + electron app ,but whenever I try to access the content on my localstorage via electron,it does not return any data .How do I go abt this ? I shd be able to access the object stored in local storage

serene patio
#

You’re sure you’re in the renderer process?

lilac wadi
#

I am trying to access it in a folder that has all the IPC calls

#

I think that's the renderer process

#

@serene patio there ?

serene patio
limber eagle
#

localStorage doesnt work properly with file protocol

lilac wadi
limber eagle
#

file://

lilac wadi
#

Just checked now.Turns out I'm in a main process

limber eagle
#

then localStorage is undefined i guess

lilac wadi
#

if (process.type === "browser") {
console.log("This is the main process");
} else if (process.type === "renderer") {
console.log("This is a renderer process");
}

#

Checked with this condition

limber eagle
#

you can check if localStorage exists

lilac wadi
#

I am logging just localStorage it does not print anything on the console

limber eagle
#

console.log(typeof localStorage)

lilac wadi
#

undefined

limber eagle
#

undefined

lilac wadi
#

?

#

so how do I access localstorage in this IPC call ?

limber eagle
#

you cant

#

if you need data persistence use other types of storage

lilac wadi
#

And they are ?

limber eagle
#

depends on amount of data

lilac wadi
#

Can you name some ?

limber eagle
#

sqlite

lilac wadi
#

cool.