1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-17 20:40:32 +09:00
namae/api/util/http.js

15 lines
326 B
JavaScript

const fetch = require('isomorphic-unfetch')
exports.fetch = (url, method = 'HEAD') => {
return fetch(url, { method })
}
exports.send = (res, data) => {
res.setHeader('Cache-Control', 'maxage=0, s-maxage=43200')
res.json(data)
}
exports.sendError = (res, error) => {
res.status(400).json({ error: error.message })
}