-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
32 lines (31 loc) · 940 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var fetch = require("node-fetch");
const cors = require("cors")();
//===========================================================================
// Get the topic types from ORM site
//===========================================================================
exports.posts = (req, res) => {
// Parse the body to get the passed values
var params;
try {
// try to parse the body for passed parameters
params = JSON.parse(req.body);
} catch (e) {
// provide default values if there is an error
params = { page: 1 };
}
// Wrap function in a CORS header so is can be called in the browser
cors(req, res, () => {
// Lookup the account type based on the email.
fetch(
"https://gateway.oreilly.com/clients/website/feed/all/page/" +
params["page"],
{}
)
.then(res => {
return res.json();
})
.then(data => {
res.send(data["posts"]);
});
});
};