You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/api/Response.ts
+16-3Lines changed: 16 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,15 @@ export default class Response {
41
41
* Save response data to the store.
42
42
*/
43
43
asyncsave(): Promise<void>{
44
-
this.entities=awaitthis.model.insertOrUpdate({
45
-
data: this.getDataFromResponse()
46
-
})
44
+
constdata=this.getDataFromResponse()
45
+
46
+
if(!this.validateData(data)){
47
+
console.warn('[Vuex ORM Axios] The response data could not be saved to the store because it\'s not an object or an array. You might want to use `dataTransformer` option to handle non-array/object response before saving it to the store.')
48
+
49
+
return
50
+
}
51
+
52
+
this.entities=awaitthis.model.insertOrUpdate({ data })
47
53
48
54
this.isSaved=true
49
55
}
@@ -75,4 +81,11 @@ export default class Response {
75
81
76
82
returnthis.response.data
77
83
}
84
+
85
+
/**
86
+
* Validate if the given data is insertable to Vuex ORM.
87
+
*/
88
+
privatevalidateData(data: any): data is Record|Record[]{
0 commit comments