【发布时间】:2019-12-07 02:09:25
【问题描述】:
我尝试初始化 Stitch 默认应用客户端,但在初始化客户端时总是出错。
这是我的代码:
import React from 'react';
import {View, Text, SafeAreaView} from 'react-native';
import {Stitch, AnonymousCredential} from 'mongodb-stitch-react-native-sdk';
class App extends React.Component {
render() {
return (
<SafeAreaView>
<View>
<Text>Stitch Test</Text>
</View>
</SafeAreaView>
);
}
async componentDidMount() {
console.log('=> App/componentDidMount');
await this._loadClient();
}
_loadClient() {
console.log('=> App/_loadClient');
Stitch.initializeDefaultAppClient('tuto - nbmzq').then(client => {
if (client.auth.isLoggedIn) {
client.auth
.loginWithCredential(new AnonymousCredential())
.then(user => {
console.log('Successfully logged in as user ${user.id}');
})
.catch(err => {
console.log(err);
});
} else {
console.log(client);
console.log('Error initialize Client'); // Always fall here
}
});
}
}
export default App;
应用 ID 存在,我可以在 MongoDB 站点上连接它。 我哪里错了?
谢谢 ++ 埃里克
【问题讨论】:
-
这似乎是一个特定于库的问题,你应该在那里打开一个新问题 git repo stitch-js-sdk
标签: react-native mongodb-stitch