Data clone error

#1

I am trying to store array of data in storage, but in i’m getting these errors, please get me some solution
ERROR Error: Uncaught (in promise): DataCloneError: Failed to execute ‘put’ on ‘IDBObjectStore’: function (responseObserver) {
var _xhr = browserXHR.build();
_xhr.open(RequestMethod[re…… } could not be cloned.
Error: Failed to execute ‘put’ on ‘IDBObjectStore’: function (responseObserver) {
var _xhr = browserXHR.build();

#2

What is your ionic info output?
Where and how are you testing?

#3

Can you call JSON.stringify() on this array?

#4

I am testing in Chrome
and these error i’m getting
ERROR Error: Uncaught (in promise): DataCloneError: Failed to execute ‘put’ on ‘IDBObjectStore’: function (responseObserver) {
var _xhr = browserXHR.build();
_xhr.open(RequestMethod[re… } could not be cloned.
Error: Failed to execute ‘put’ on ‘IDBObjectStore’: function (responseObserver) {
var _xhr = browserXHR.build();

#5

core.es5.js:1084 ERROR Error: Uncaught (in promise): DataCloneError: Failed to execute ‘put’ on ‘IDBObjectStore’: function (responseObserver) {
var _xhr = browserXHR.build();
_xhr.open(RequestMethod[re…… } could not be cloned.
Error: Failed to execute ‘put’ on ‘IDBObjectStore’: function (responseObserver) {
var _xhr = browserXHR.build();
_xhr.open(RequestMethod[re…… } could not be cloned.
at localforage.js:944
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.es5.js:4128)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.es5.js:4119)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at localforage.js:944
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.es5.js:4128)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.es5.js:4119)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at c (polyfills.js:3)
at polyfills.js:3
at polyfills.js:3
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.es5.js:4128)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.es5.js:4119)

#6

You have to run ionic info in the command line in your project directory.

#7

yea had done, its getting package information. what is the use of this ? how its help to debug data clone error

#8

It tells me your operating system, the versions of the packages you installed, etc.

But you don’t have to post it, I just won’t help you then. Good luck.

#9

Its Packages details bro, Please Help me
global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 3.3.0

System:

Node       : v7.10.0
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 4.2.0
#10

Upgrade that to at least 1.3.12, better 2.x (but read the changelog).

No reason to not update this to 3.5.

Rest looks fine.

After you made these updates, post your ionic info again and the code that is causing the error you posted. Right now I have no idea what you are actually doing.

#11

I am trying to save Array of element to ionic storage, taking data in the format of JSON, the code is here,

import { Injectable } from ‘@angular/core’;
import { Post } from ‘…/providers/wp-provider/wp-provider’;
import { Storage } from ‘@ionic/storage’;

@Injectable()
export class QuotesService {

private favoriteQuotes: Post[] = [];
private readQuotes: Post[] = [];

constructor(public storage: Storage) { }

addQuoteToFavorites(quote: Post) {
this.favoriteQuotes.push(quote);
console.log(this.favoriteQuotes);

}

removeQuoteFromFavorites(quote: Post) {
const position = this.favoriteQuotes.findIndex((quoteEl: Post) =>{
return quoteEl.id == quote.id;
});
this.favoriteQuotes.splice(position, 1);
}

getFavoriteQuotes() {
return this.favoriteQuotes.slice();
}
addQuoteToRead(quote: Post) {
this.readQuotes.push(quote);
console.log(this.readQuotes);
}
removeQuoteFromRead(quote: Post) {
const position = this.readQuotes.findIndex((quoteEl: Post) =>{
return quoteEl.id == quote.id;
});
this.readQuotes.splice(position, 1);
}

getReadQuotes() {
return this.readQuotes.slice();
}

openPost(post){

}

}

#12

I’m not seeing where you’re doing anything with storage here.

#13

When i am using ‘set’ storage, i am getting data clone error, thank you for your’r replay

import { Injectable } from ‘@angular/core’;
import { Post } from ‘…/providers/wp-provider/wp-provider’;
import { Storage } from ‘@ionic/storage’;

@Injectable()
export class QuotesService {

private favoriteQuotes: Post[] = [];

constructor(public storage: Storage) { }

addQuoteToFavorites(quote: Post) {
this.favoriteQuotes.push(quote);
this.storage.set(‘fvrt’,this.favoriteQuotes);
}

#14

Did you ever answer my earlier question?