Skip to content

Commit 6bbbb56

Browse files
added new capability to wp-mixin
1 parent 2ff2acf commit 6bbbb56

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "vue-wordpress",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "A collection of Vue components and mixins for use with WordPress and the WP-REST API",
55
"author": "WakeCoder <ajqajq@gmail.com>",
6+
"contributes": {"Cameron Beck":"cameron-beck-coding <cameron@pixelthin.com>"},
67
"scripts": {
78
"dev": "node build/dev-server.js",
89
"start": "node build/dev-server.js",

src/mixins/wp-mixin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import 'whatwg-fetch'
55
// wpGet just wraps some of the basic fetch boilerplate
66
const wpGet = function ({ url, mapper, fetchOptions }) {
77
return fetch(url, fetchOptions)
8-
.then(res => res.json())
8+
.then(res => {
9+
if (!res.ok) {
10+
errorCallback(res)
11+
}
12+
return res.json()
13+
})
914
.then(json => {
1015
return mapper(json)
1116
})
@@ -42,6 +47,7 @@ export default {
4247
newPage.loaded = true
4348
loader.pagesLoaded++
4449
})
50+
.catch(reason=>{errorCallback(reason)})
4551
},
4652
pagesLeft: true // This should be updated based on the X-WP-TotalPages header and pagesLoaded
4753
}

0 commit comments

Comments
 (0)