F1Manager-Calc/libs/storage/cloudStorage.js
2023-04-18 15:42:24 +08:00

27 lines
737 B
JavaScript

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(
d.data ? d.data[key] : null
)).catch(r => reject(r))
})
},
setItem: (key, item) => {
return new Promise((resolve, reject) => {
axios.post(`/api/cloud/storage`, {[key]: item}).then(
r => resolve(r)
).catch(r => reject(r))
})
},
removeItem: (key) => {
return new Promise((resolve, reject) => {
axios.post(`/api/cloud/storage`, {[key]: null}).then(
r => resolve(r)
).catch(r => reject(r))
})
},
}
}