@@ -3,7 +3,7 @@ import safeGet from 'safe-get'
3
3
import 'whatwg-fetch'
4
4
5
5
// wpGet just wraps some of the basic fetch boilerplate
6
- const wpGet = function ( { url, mapper, fetchOptions, errorCallback } ) {
6
+ const wpGet = function ( { url, mapper, fetchOptions, errorCallback } ) {
7
7
return fetch ( url , fetchOptions )
8
8
. then ( res => {
9
9
if ( ! res . ok ) {
@@ -28,7 +28,7 @@ export default {
28
28
* @param {object } fetchOptions - An object that contains options for the fetch call. See https://github.github.io/fetch/ for more
29
29
* informaiton. NOTE: Must set {credentials: 'include' | 'same-site'} for endpoints requiring cookie authentication.
30
30
*/
31
- createWpLoader ( url , options , fetchOptions , errorCallback ) {
31
+ createWpLoader ( url , options , fetchOptions , errorCallback ) {
32
32
let mapper = options . mapper ? options . mapper : this . mapPosts
33
33
url += options . embed !== false ? '?_embed&' : '?'
34
34
if ( safeGet ( options , 'queryParams.length' ) > 0 ) {
@@ -42,12 +42,14 @@ export default {
42
42
const pageToLoad = loader . pagesLoaded + 1
43
43
const newPage = { loaded : false , content : [ ] }
44
44
loader . pages . push ( newPage )
45
- wpGet ( { url : url + 'page=' + pageToLoad , mapper, fetchOptions, errorCallback } ) . then ( content => {
45
+ wpGet ( { url : url + 'page=' + pageToLoad , mapper, fetchOptions, errorCallback } ) . then ( content => {
46
46
newPage . content = content
47
47
newPage . loaded = true
48
48
loader . pagesLoaded ++
49
49
} )
50
- . catch ( reason => { errorCallback ( reason ) } )
50
+ . catch ( reason => {
51
+ errorCallback ( reason )
52
+ } )
51
53
} ,
52
54
pagesLeft : true // This should be updated based on the X-WP-TotalPages header and pagesLoaded
53
55
}
0 commit comments