Intergrating with pouchDb some error

import PouchDB from 'pouchdb';
export class HomePage {
   public temp=[];
constructor()
{
  this.db = new PouchDB('cloudo');
  this.temp.push({
    "nikhil":"nikhil"
  });
  this.saveData((this.temp));
 }
  saveData(data) {
    console.log(data);
    this.db.post(data) 
  }
}

above in saveData function I am getting below error

Runtime Error
Uncaught (in promise): {"status":400,"name":"bad_request","message":"Document must be a JSON object"}

temp is an array right now, not an object.
What does the console.log(data) output?

when I console like above console.log(data) its showing like below

[Object]

Just to show what I mean, please duplicate the push line and show the log output again.

kept like this

 this.temp.push({
    "nikhil":"nikhil"
  });
  this.temp.push({
    "niks":"nikhil"
  });

got this

 [Object, Object]

hey I gave like this

 public temp:Object;
this.temp={
    "nikhil":"nikhil"
  };

now its showing

 {status: 412, name: "missing_id", message: "_id is required for puts", error: true, __zone_symbol__currentTask: t}

but in above multiple times if I want to push then will be prob… for me

Which means you have 2 objects in an array. Error message tells you, that you need one object. So your code is wrong and won’T work.

See, now you have the correct data type and get a new error. What does console.log output now before you do the pouchdb stuff?

Object {nikhil: "nikhil"}

Now connect that with the error message, that tells you that you need _id in there for what you want to do…

gave like this

 this.temp={
    "_id " :1,
    "nikhil":"nikhil"
  };

but still same error

I have no idea about PouchDB, but googling for “pouchdb getting started” gave me this on #1: https://pouchdb.com/getting-started.html#write_todos_to_database

hmm ok thanks will see