forked from fluree/auth-pass-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetComics.js
More file actions
33 lines (31 loc) · 890 Bytes
/
getComics.js
File metadata and controls
33 lines (31 loc) · 890 Bytes
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
33
const fs = require("fs");
const axios = require("axios");
const url = "https://api.shortboxed.com/comics/v1/new";
axios
.get(url)
.then((res) => {
console.log(res);
const { comics } = res.data;
// console.log(comics);
const transactions = comics.map((book, index) => {
return {
_id: `comic?${index}`,
title: book.title,
price: book.price,
publisher: book.publisher,
description: book.description,
creators: book.creators,
release_date: book.release_date,
diamond_id: book.diamond_id,
};
});
console.log(transactions);
fs.writeFile("bookData.json", JSON.stringify(transactions), (err) => {
if (err) throw err;
console.log("The file has been saved!");
});
})
.catch((err) => {
console.log("The Shortboxed API is not responding");
console.log(err);
});