Reactjs &引用;网络错误:尝试获取资源时出现NetworkError;
我正在使用graph.cool api和react和apollo。我正在使用graph.cools默认电子邮件传递集成构建一个身份验证系统。不知何故,登录变异工作完美无瑕,但注册变异不起作用。 注:登录和注册功能在同一页面。登录工作注册表不可用 注册功能:Reactjs &引用;网络错误:尝试获取资源时出现NetworkError;,reactjs,graphql,react-apollo,apollo-client,Reactjs,Graphql,React Apollo,Apollo Client,我正在使用graph.cool api和react和apollo。我正在使用graph.cools默认电子邮件传递集成构建一个身份验证系统。不知何故,登录变异工作完美无瑕,但注册变异不起作用。 注:登录和注册功能在同一页面。登录工作注册表不可用 注册功能: async register(){ await client.mutate({ mutation: gql` mutation createUser($email: String!, $password: String!){ c
async register(){
await client.mutate({
mutation: gql`
mutation createUser($email: String!, $password: String!){
createUser(
authProvider : {
email: {
email: $email,
password: $password
}
}
) {
id
}
}
`,
variables: {
email: this.state.regEmail,
password: this.state.regPass
},
})
.then(result => { this.props.history.push({
pathname: '/dashboard',
state: { logInfo: [result.data.signinUser.token,
result.data.signinUser.user.id] }
});
})
.catch(error => { console.log(error)});
}
async login(){
await client.mutate({
mutation: gql`
mutation signinUser($email: String!, $password: String!){
signinUser(
email: { email: $email, password: $password }
) {
token
user {
id
email
name
phone
prescriptions {
docname
docid
details
med
}
}
}
}
`,
variables: {
email: this.state.loginEmail,
password: this.state.loginPass
},
})
.then(result => { this.props.history.push({
pathname: '/dashboard',
state: { logInfo: [result.data.signinUser.token,
result.data.signinUser.user.id] }
});
})
.catch(error => { alert("Incorrect username or password") });
}
登录功能:
async register(){
await client.mutate({
mutation: gql`
mutation createUser($email: String!, $password: String!){
createUser(
authProvider : {
email: {
email: $email,
password: $password
}
}
) {
id
}
}
`,
variables: {
email: this.state.regEmail,
password: this.state.regPass
},
})
.then(result => { this.props.history.push({
pathname: '/dashboard',
state: { logInfo: [result.data.signinUser.token,
result.data.signinUser.user.id] }
});
})
.catch(error => { console.log(error)});
}
async login(){
await client.mutate({
mutation: gql`
mutation signinUser($email: String!, $password: String!){
signinUser(
email: { email: $email, password: $password }
) {
token
user {
id
email
name
phone
prescriptions {
docname
docid
details
med
}
}
}
}
`,
variables: {
email: this.state.loginEmail,
password: this.state.loginPass
},
})
.then(result => { this.props.history.push({
pathname: '/dashboard',
state: { logInfo: [result.data.signinUser.token,
result.data.signinUser.user.id] }
});
})
.catch(error => { alert("Incorrect username or password") });
}