index.json.js 263 B

12345678910111213141516
  1. import posts from './_posts.js';
  2. const contents = JSON.stringify(posts.map(post => {
  3. return {
  4. title: post.title,
  5. slug: post.slug
  6. };
  7. }));
  8. export function get(req, res) {
  9. res.writeHead(200, {
  10. 'Content-Type': 'application/json'
  11. });
  12. res.end(contents);
  13. }