Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add headers option #917

Closed
wants to merge 3 commits into from
Closed

Add headers option #917

wants to merge 3 commits into from

Conversation

solisoft
Copy link

@solisoft solisoft commented May 28, 2020

This PR allow a user to set extra headers on each requests using the headers options

Here a usage

$('.videos').infiniteScroll({
    append: false,
    history: false,
    responseType: 'text',
    headers: function () {
      return [['X-Session-Id', localStorage.getItem('X-SessionFront-Id')]]
    },
    path: function() {
      self.current_page = this.loadCount + 2
      if( self.current_page <= count ) {
        return path + self.current_page
      }
      self.update()
    },
    status: '.scroll-status',
})

@desandro
Copy link
Member

desandro commented Dec 6, 2020

Thank you for this contribution! This looks straightforward. I may re-tool this a bit.

Related #791

@desandro
Copy link
Member

Infinite Scroll v4 has been released. Infinite Scroll v4 adds a new option, fetchOptions, which allows you to set headers and other fetch options.

fetchOptions: {
  mode: 'cors',
  cache: 'no-cache',
  credentials: 'same-origin',
  headers: {
    'X-Session-Id': '33vscths658h7996d324rqft1s',
  },
},

Thank you for your original contribution. While I did not merge it in, your effort did help me decide to support the feature.

@desandro desandro closed this Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants