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

15 lines
323 B
JavaScript

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