init
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user