Closed mqtik closed 5 years ago
Hi! Thanks for the issue.
You are saying that your code snippet throws an error, right ? Would you mind sharing the error that is output to console please ?
Just to be clear, the signUp
method is for creating a user. To actually log in, you have to use the logIn
method.
Yes, I did use this library before in web development. This is the first time using it with React Native.
Well, this is the output:
Seems like pouchdb-ajax is giving problems
From the look of the error, it seems that this has nothing to do with PouchDB Authentication.
You omitted to fill in the provided template for issues. So please provide all the information that was requested. We need those.
@matikups I experienced the issue you're having with React Native many years ago. You are probably missing the blob polyfill (among other things).
Here is my current config to get PouchDB 7.0.0 to work in React Native...
// File: pouchdb-dependencies.js
// These are used for PouchDB's checks to make sure SQLite is present
import SqlitePlugin from 'react-native-sqlite-storage';
import { Buffer } from 'buffer';
import 'blob-polyfill';
global.cordova = global.cordova || true;
global.sqlitePlugin = global.sqlitePlugin || SqlitePlugin;
global.openDatabase = global.openDatabase || true;
process.nextTick = process.nextTick || setImmediate;
// These rest are polyfills to make sure that btoa, atob, and blob are present for PouchDB to serialize/deserialize properly
global.Buffer = global.Buffer || Buffer;
if (typeof btoa === 'undefined') {
global.btoa = function (str) {
return new Buffer(str).toString('base64');
};
}
if (typeof atob === 'undefined') {
global.atob = function (b64Encoded) {
return new Buffer(b64Encoded, 'base64').toString();
};
}
// File: cleverpoint-pouch-react-native.js
import './pouchdb-dependencies';
import PouchDB from 'pouchdb-core';
import CordovaSQLitePouch from 'pouchdb-adapter-cordova-sqlite';
import HttpPouch from 'pouchdb-adapter-http';
import replication from 'pouchdb-replication';
import mapreduce from 'pouchdb-mapreduce';
import UpsertPouch from 'pouchdb-upsert';
PouchDB
.plugin(CordovaSQLitePouch)
.plugin(HttpPouch)
.plugin(replication)
.plugin(mapreduce)
.plugin(UpsertPouch);
export default PouchDB;
// File: calling-code.js
import PouchDB from './cleverpoint-pouch-react-native';
const db = new PouchDB('my_database', { adapter: 'cordova-sqlite' });
Hope this helps!
@PaulMest thanks for your response!
Well, I found out that the problem was due to the React/React Native version.
ReactNative 16 ships with support for Blobs. I had version 15. There's still problems with PouchDB-React-Native. It seems like it doesn't support quiet yet _attachments.
Closing, since this issue's solved.
Hello everyone,
I'm trying to make this work with the plugin PouchDB Authentication, with no luck.
It throws an error: Reference error: Blob is not defined
I tried to install another library reading blob, change the source code, among other things, but still wont work.
Hope you can help me out with this.
Kind regards.