azury
Version:
Powerful Javascript SDK for Azury
28 lines (23 loc) • 1.64 kB
JavaScript
import fetch from 'node-fetch'
import { secret } from '../index.js'
import { endpoint } from '../config.js'
export async function GET(url, body) {
if (body) return await fetch(endpoint + url, { method: 'GET', body: JSON.stringify(body), headers: { 'content-type': 'application/json', authorization: secret }})
return await fetch(endpoint + url, { method: 'GET', headers: { authorization: secret }})
}
export async function POST(url, body) {
if (body) return await fetch(endpoint + url, { method: 'POST', body: JSON.stringify(body), headers: { 'content-type': 'application/json', authorization: secret }})
return await fetch(endpoint + url, { method: 'POST', headers: { authorization: secret }})
}
export async function PUT(url, body) {
if (body) return await fetch(endpoint + url, { method: 'PUT', body: JSON.stringify(body), headers: { 'content-type': 'application/json', authorization: secret }})
return await fetch(endpoint + url, { method: 'PUT', headers: { authorization: secret }})
}
export async function PATCH(url, body) {
if (body) return await fetch(endpoint + url, { method: 'PATCH', body: JSON.stringify(body), headers: { 'content-type': 'application/json', authorization: secret }})
return await fetch(endpoint + url, { method: 'PATCH', headers: { authorization: secret }})
}
export async function DELETE(url, body) {
if (body) return await fetch(endpoint + url, { method: 'DELETE', body: JSON.stringify(body), headers: { 'content-type': 'application/json', authorization: secret }})
return await fetch(endpoint + url, { method: 'DELETE', headers: { authorization: secret }})
}