metafizzy / infinite-scroll

📜 Automatically add next page
https://infinite-scroll.com
7.41k stars 1.74k forks source link

method request #905

Closed leonnleite closed 3 years ago

leonnleite commented 4 years ago

Add method option and param option

let count = 0;
...
method: 'POST', 
params: function() { 
   return {foo: 'bar', baz: 'qux', count: ++count}; 
}
...

params could be:

let foo = 'bar';
params: {bar}

params: {foo: 'bar'}

params: document.getElementById('formSection')

params: 'foo=bar&baz=qux'

params: function() {...} 

params: () => {...} 

the XMLHttpRequest replaced to fetch

desandro commented 3 years ago

Infinite Scroll v4 has been released. Infinite Scroll v4 adds a new option, fetchOptions, which allows you to set method, headers, CORS mode, and other options for the fetch request

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.