Skip to content

Commit

Permalink
feat(api): md to html converter
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin.apolinario committed Dec 4, 2023
1 parent 0aff16c commit f363b1b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/pages/api/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// pages/api/fetchData.js

import axios from 'axios';
import MarkdownIt from 'markdown-it';

export default async function handler(req, res) {
const token = req.query['token'];
const url =
'https://8-aaeffee09b-7w6v22.api.zesty.io/v1/content/models/6-e092db91a5-rgfcx2/items?limit=5000&page=1&lang=en-US';

const auth = 'Bearer ' + token;

const response = await axios.get(url, { headers: { Authorization: auth } });

const md = new MarkdownIt();

const data = response.data.data.map((e) => {
const content = md.render(e.data.body).replaceAll('\n', '');
return { item: e.meta.ZUID, content };
});
res.status(200).json({ data });
}

0 comments on commit f363b1b

Please sign in to comment.