【发布时间】:2020-04-22 01:32:29
【问题描述】:
在我的项目上运行meteor reset 后发生此错误
Uncaught TypeError: Cannot read property 'findOne' of undefined
at onLoginWithGoogle (Heading.js:23)
at Button._this.handleClick (modules.js?hash=aa2df6fbe7f4a6a52d262a213d0cfff2a56dcdc2:10098)
at HTMLUnknownElement.callCallback (modules.js?hash=aa2df6fbe7f4a6a52d262a213d0cfff2a56dcdc2:32249)
...
这是调用 ServiceConfiguration 的文件:
Heading.js
import React, { useContext, useState } from 'react'
import { Meteor } from 'meteor/meteor';
import ServiceConfiguration from 'meteor/service-configuration'
...
function Heading(props){
const context = useContext(Context);
const [error, setError] = useState('');
const onLoginWithGoogle = () => {
const {scope} = ServiceConfiguration.configurations.findOne({service: 'google'}); //this is where it failed
Meteor.loginWithGoogle(
{requestPermissions: scope, requestOfflineToken: true },
error => {
if (error) {
if (error.errorType === 'Accounts.LoginCancelledError') return;
alert('Login error', error);
} else {
//
}
}
);
};
}
//export
服务配置存储在service-configuration.js文件下的server文件夹中:
import { ServiceConfiguration } from 'meteor/service-configuration';
ServiceConfiguration.configurations.update(
{ service: 'google' },
{
$set: {
clientId: 'XXX',
loginStyle: 'popup',
secret: 'XXXX'
}
}
);
我无法理解这个错误。在我运行 meteor reset 之前它就可以工作了。
【问题讨论】:
标签: meteor