29 lines
874 B
TypeScript
29 lines
874 B
TypeScript
(async function () {
|
|
const res = await fetch("http://all.funjia.top/api/dynamic/list/dataDict", {
|
|
method: "post",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({ "page": 1, "pageSize": 100000, "userId": "cl3fqx6zb000034ny90rd333s" })
|
|
});
|
|
|
|
const importData = await res.json();
|
|
importData.data.forEach(element => {
|
|
console.log(element)
|
|
saveData({ unionKey: element.unionKey, value: element.value, desc: element.desc });
|
|
});
|
|
})()
|
|
|
|
function saveData(importData) {
|
|
fetch("http://127.0.0.1:1337/api/data-dicts", {
|
|
method: "post",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({ data: importData })
|
|
}).then((res) => {
|
|
console.log(res);
|
|
}).catch((err) => {
|
|
console.log(err)
|
|
})
|
|
} |