My login query doesn't work #2030
-
My query doesn't work (it's a basic login query) urql version & exchanges: latest Steps to reproduce Here is the full page: import React, { useEffect, useState } from "react"; interface LoginProps {} const LOG_MUT = const Login: React.FC = ({}) => { LoginLogin {setUser({login: event.target.value, password: user.password})}} className={styles.inputclass} type="text" placeholder="Enter Login" name="login" required /> Password {setUser({login: user.login, password: event.target.value})}} className={styles.inputclass} type="password" placeholder="Enter Password" name="psw" id="psw" required /> {Login({login: user.login, password: user.password}); if(result.data.Login.errors != null){alert(JSON.stringify(result.data.createUser.errors[0].message))} else {alert(JSON.stringify(result.data.login.user))}}} type="submit" className={styles.Loginbtn}>Login Don't have an account? Sign Up here!. export default Login; Expected behavior It should tell you if your user exists or not by alert() Actual behavior It says that there is no password or login, but I'm just sure that above code is wrong, because I'm used to mutations and queries are not my forte. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You haven't passed in |
Beta Was this translation helpful? Give feedback.
You haven't passed in
variables
touseQuery
, so that explains the error you're seeing. On a side note however, since this is a stateful side effect (logging in is an action that a user takes), you'd want to use a mutation for that ❤️