We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b4e3022 + e0802a1 commit 7a506dfCopy full SHA for 7a506df
functions/blog.js
@@ -0,0 +1,23 @@
1
+//ISR (incremental static rendering) function that communicates to Netlify
2
+const fetch = require('node-fetch');
3
+
4
+exports.handler = async (event, context) => {
5
+ const res = await fetch('https://dev.to/api/articles?username=wdp');
6
+ const posts = await res.json();
7
8
+ return {
9
+ statusCode: 200,
10
+ headers: { 'content-type': 'application/json' },
11
+ body: JSON.stringify({
12
+ posts: posts.map(post => ({
13
+ title: post.title,
14
+ image: post.cover_image,
15
+ altTag: post.title,
16
+ content: post.description,
17
+ link: post.url,
18
+ linkText: 'Read more',
19
+ tagList: post.tag_list,
20
+ })),
21
+ }),
22
+ };
23
+};
0 commit comments