gridsome.server.js 437 B

12345678910111213141516171819
  1. const axios = require('axios')
  2. module.exports = function (api) {
  3. api.loadSource(async store => {
  4. const { data } = await axios.get('http://api.archives-ouvertes.fr/search/?q=docid:2172000&fl=*')
  5. const contentType = store.addContentType({
  6. typeName: 'article',
  7. })
  8. let item = data.response.docs[0];
  9. contentType.addNode({
  10. id: item.docid,
  11. title: item.title_s[0],
  12. path:"article",
  13. })
  14. })
  15. }