I am facing issue with pouchdb and ionic on mobile device for first launching the app?

i have provider in my app which contains following code

constructor() {
		this.remote = 'http://172.16.0.4:5984/cmsdata';
		this.db = new PouchDB('cmsdata');
		let options = {
			live: true,
			continuous: true
		};
		this.db.sync(this.remote, options);
		console.log("hey satya you are a leader");
		console.log(this.db);
	}

using below function i am getting data from provider

getdata(){
`              if (this.data) {
			return Promise.resolve(this.data);
		}
		return new Promise(resolve => {
			this.db.allDocs({
				include_docs: true
			}).then((result) => {
				this.data = [];	
				let docs = result.rows.map((row) => {
					//console.log(row.doc);
					this.data.push(row.doc);
				});
				resolve(this.data);
				console.log(this.data);
				this.db.changes({live: true, since: 'now', include_docs: true}).on('change', (change) => {
					this.handleChange(change);
				});
				
			}).catch((error) => {

				console.log(error);

			});

		});
}

when i am using this with web app using ionic serve or ionic-lab it’s working fine but when it comes to mobile app for first time launch it’s not getting data
showing following errors

polyfills.js:3 GET http://172.16.0.4:5984/cmsdata/_local/u.OVbtFswWUxRMQf4bp9.w%3D%3D?_nonce=1507709009779 404 (Object Not Found)
The above 404 is totally normal. PouchDB is just checking if a remote checkpoint exists.


GET http://172.16.0.4:5984/cmsdata/_local/1Y_akp34dMPdLetxuVpU_A%3D%3D?_nonce=1507709011300 404 (Object Not Found)
The above 404 is totally normal. PouchDB is just checking if a remote checkpoint exists.

can anyone help me how to resolve this problem?

Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

If this is the error you are referring to, did you read it? It says this is normal.

hello @Sujan12,
I have seen that

 The above 404 is totally normal. PouchDB is just checking if a remote checkpoint exists.

you need to understand one thing it’s saying that it’s checking for remote checkpoint exists.I am just launching the app for the first time so it doesn’t have any data previously because of that i am getting empty array.

So what do you expect? What is wrong?

@Sujan12 i am expecting the data for the first time also when we launch the app.If we stop checking for remote for the first time then it will sync data from couchdb then it’s works as usual.Right now if i launch the app second time it’s working fine i mean it’s able to get the data.

Does it do the same requests, but then doesn’t get a 404?
Where does it get the data from?

Finally we solved the issue…The reason is you are trying to get the data before it’s finishing sync or replicate.You have to wait for sync or replication completion after that only you need to call the functions to get the data.We handled this case showing loading symbol while syncing and replicating when it’s done.We are trying to call the functions.

I have contributed this to github. it may help someone…