alok8bb 0a50433345
chore: minor changes & better error handling
Signed-off-by: alok8bb <alok8bb@gmail.com>
2022-12-13 19:31:29 +05:30

29 lines
555 B
TypeScript

import { SERVER_URL } from "../util";
export const setPaste = async (code: string) => {
try {
return await fetch(SERVER_URL + "/bin/paste", {
method: "POST",
headers: { "Content-type": "text/plain" },
body: code,
});
} catch (err) {
console.error(err);
return null;
}
};
export const getPaste = async (pasteId: string) => {
try {
const response = await fetch(`${SERVER_URL}/bin/paste/${pasteId}`);
return response;
} catch (err) {
return null;
}
};
export interface SuccessResponse {
message: string;
endpoint: string;
}