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

15 lines
345 B
JavaScript
Raw Normal View History

2019-08-05 22:59:39 +09:00
const fetch = require('isomorphic-unfetch')
exports.fetch = (url, method = 'HEAD') => {
return fetch(url, { method })
}
exports.send = (res, availability) => {
res.setHeader('Cache-Control', 'maxage=0, s-maxage=3600')
res.json({ availability })
}
exports.sendError = (res, error) => {
res.status(400).json({ error: error.message })
}