UNPKG

@teenth/sdk-tool

Version:

sdk-tool with R2 storage support

39 lines (38 loc) 875 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RES_MESSAGE = exports.RES_CODE = exports.post = exports.get = void 0; const get = async (url, options) => { const res = await fetch(url, options); if (res.ok) { return res.json(); } return { code: res.status, message: res.statusText, }; }; exports.get = get; const post = async (url, options) => { const res = await fetch(url, { method: "POST", ...options, body: JSON.stringify(options?.body), }); if (res.ok) { const data = await res.json(); return data; } return { code: res.status, message: res.statusText, }; }; exports.post = post; exports.RES_CODE = { SUCCESS: 200, ERROR: 500, }; exports.RES_MESSAGE = { SUCCESS: "success", ERROR: "error", };