Fetching external data

    In this example we will see how to daily fetch Docker pull count to store the result in your database.

    First, we need to create a Content Type, in this example we will call it hit with a date and count attribute.

    Your Content Type should look like this:

    Now we will create a function that will be usable everywhere in your strapi application.

    Path — ./config/functions/docker.js

    data contains all the data received from the Docker Hub API. What we want here is to add the pull_count value in your database.

    Path — ./config/functions/docker.js

    With this code, everytime this function is called it will fetch the docker repo’s data and insert the current pull_count with the corresponding date in your Strapi database.

    Here is how to call the function in your application strapi.config.functions.docker()

    Path —