javascript – Withdrawing posts from instagram on the site

Question:

Greetings! On the site http://isvektor.beget.tech/ , posts from instagram are displayed using Instafeed.js. The conclusion seems to be implemented, but with the installation of the "Load more" button. How should it be implemented at all? On the plug-in developer's site, there is such a code, but I don't know how to use it. I display posts like this:

$(document).ready(function() {


var userFeed = new Instafeed({
    get: 'user',
    userId: 'userid',
    limit: 7,
    resolution: 'standard_resolution',
    accessToken: 'tokenid',
    sortBy: 'most-recent',
    template: '<div class="rol-lg-2 instaimg"><a href="{{link}}" target="_blank"><img src="{{image}}" alt="{{caption}}" class="img-fluid"/></a></div>',
});


userFeed.run();

});

var loadButton = document.getElementById('load-more');
var feed = new Instafeed({
    // every time we load more, run this function
    after: function() {
        // disable button if no more results to load
        if (!this.hasNext()) {
            loadButton.setAttribute('disabled', 'disabled');
        }
    },
});

// bind the load more button
loadButton.addEventListener('click', function() {
    feed.next();
});

// run our feed!
feed.run();

Answer:

And if you combine both methods?

var loadButton = document.getElementById('load-more');
var feed = new Instafeed({

    get: 'user',
    userId: 'userId',
    limit: 7,
    resolution: 'standard_resolution',
    accessToken: 'accessToken',
    sortBy: 'most-recent',
    template: '<div class="rol-lg-2 instaimg"><a href="{{link}}" target="_blank"><img src="{{image}}" alt="{{caption}}" class="img-fluid"/></a></div>',

    // every time we load more, run this function
    after: function() {
        // disable button if no more results to load
        if (!this.hasNext()) {
            loadButton.setAttribute('disabled', 'disabled');
        }
    },
});

// bind the load more button
loadButton.addEventListener('click', function() {
    feed.next();
});

// run our feed!
feed.run();

I hid your data, which I advise you too

Scroll to Top