Add Paul's Toolbox Contents
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { PlasmoMessaging } from "@plasmohq/messaging";
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
|
||||
const { token, siteUrl } = await chrome.storage.local.get(["token", "siteUrl"]);
|
||||
|
||||
if (req.body.action === "submitAddForm") {
|
||||
const { values } = req.body;
|
||||
const formData = new FormData();
|
||||
|
||||
Object.keys(values).forEach((item) => {
|
||||
formData.append(item, String(values[item]));
|
||||
});
|
||||
|
||||
const addReq = await fetch(`${siteUrl}/api/read/add`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
"paul-token-code": token,
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
|
||||
res.send(addReq);
|
||||
}
|
||||
}
|
||||
|
||||
export default handler;
|
||||
@@ -1,13 +0,0 @@
|
||||
import type { PlasmoMessaging } from "@plasmohq/messaging"
|
||||
|
||||
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
|
||||
const message = await fetch('https://paul.ren/api/note').then((res) => res.json());
|
||||
|
||||
console.log(message);
|
||||
|
||||
res.send({
|
||||
message
|
||||
})
|
||||
}
|
||||
|
||||
export default handler
|
||||
Reference in New Issue
Block a user