123456789101112131415161718192021222324252627282930313233343536 |
- const axios = require('axios');
- const crypto = require('crypto');
- exports.sourceNodes = async ({ boundActionCreators }) => {
- const { createNode } = boundActionCreators;
- const fetchEntry = () => axios.get("http://api.archives-ouvertes.fr/search/?q=docid:410979&fl=*");
- const res = await fetchEntry();
- r = res.data.response.docs[0];
- console.log("ddd");
- const articleNode = {
- id : "0",
- parent: `__SOURCE__`,
- internal:{
- type: `Truc`
- },
- children: [],
- // Custom data
- docid: r.docid,
- title: r.title_s[0],
- pages: r.page_s
- }
- const contentDigest = crypto
- .createHash(`md5`)
- .update(JSON.stringify(articleNode))
- .digest(`hex`);
- articleNode.internal.contentDigest = contentDigest;
- createNode(articleNode);
- return;
- }
|