2023-04-18 09:23:55 +02:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
export default function createWebStorage(type) {
|
|
|
|
return {
|
|
|
|
getItem: (key) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
axios.get(`/api/cloud/storage`).then(d => resolve(
|
2023-04-18 09:25:15 +02:00
|
|
|
d.data ? d.data[key] : null
|
2023-04-18 09:23:55 +02:00
|
|
|
))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
setItem: (key, item) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
resolve(axios.post(`/api/cloud/storage`, {[key]: item}))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
removeItem: (key) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
resolve(axios.post(`/api/cloud/storage`, {[key]: null}))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|