Add external sources

Create a service with a function that gets the data and stores it in collection.

module.exports = {
   fetchData: async () => {
         let collectionType = 'candidates';
         let { data } = await axios.get('https://your_external_source.com/api/');
         for (const key in data) {
           let candidate = data[key];
           await strapi.query(collectionType).create(candidate);
         }
}

You can call it like this: strapi.services[serviceName].fetchData() in cron or in a controller, depends on your needs.

1 Like