init project
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const axios = require('axios'),
|
||||
fs = require('fs');
|
||||
let param = JSON.parse(fs.readFileSync('param.JSON', 'utf-8'))
|
||||
|
||||
module.exports = function(api) {
|
||||
api.loadSource(async actions => {
|
||||
for (let d in param.meta) {
|
||||
actions.addMetadata(d, param.meta[d])
|
||||
}
|
||||
if (!param.search) throw "Nothing to search for";
|
||||
// Ajout des recherches
|
||||
let search = param.search.map(s => {
|
||||
return axios.get(`${param.source}${s}`);
|
||||
});
|
||||
await axios.all(search).then(res => {
|
||||
param.search.forEach((p, index) => {
|
||||
let action = actions.addCollection(p),
|
||||
{
|
||||
data
|
||||
} = res[index];
|
||||
for (const item of data) {
|
||||
action.addNode({
|
||||
id: item.id,
|
||||
titre: item.Titre,
|
||||
contenu: item.Contenu
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user