Skip to content

Commit b5370c9

Browse files
committed
removing unused var
1 parent ddc5d9e commit b5370c9

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

front-end/src/Signup.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
import React, { useState, useEffect } from "react"
2-
import { Link, Navigate, useSearchParams } from "react-router-dom"
3-
import axios from "axios"
1+
import React, { useState, useEffect } from "react";
2+
import { Link, Navigate, useSearchParams } from "react-router-dom";
3+
import axios from "axios";
44
// import logo from './logo.svg';
5-
import "./Login.css"
5+
import "./Login.css";
66

77
const Signup = props => {
8-
let [urlSearchParams] = useSearchParams() // get access to the URL query string parameters
8+
// let [urlSearchParams] = useSearchParams() // get access to the URL query string parameters
99

1010
// create state variables to hold username and password
11-
const [response, setResponse] = useState({}) // the API will return an object with a JWT token, if the user logs in successfully
12-
const [errorMessage, setErrorMessage] = useState("")
11+
const [response, setResponse] = useState({}); // the API will return an object with a JWT token, if the user logs in successfully
12+
const [errorMessage, setErrorMessage] = useState("");
1313

1414
// if the user's logged-in status changes, save the token we receive from the server
1515
useEffect(() => {
1616
// if the user is logged-in, save the token to local storage
1717
if (response.success && response.token) {
18-
console.log(`User successfully logged in: ${response.username}`)
19-
localStorage.setItem("token", response.token) // store the token into localStorage
18+
console.log(`User successfully logged in: ${response.username}`);
19+
localStorage.setItem("token", response.token); // store the token into localStorage
2020
}
21-
}, [response])
21+
}, [response]);
2222

2323
// what to do when the user clicks the submit buton on the form
2424
const handleSubmit = async e => {
2525
// prevent the HTML form from actually submitting... we use React's javascript code instead
26-
e.preventDefault()
26+
e.preventDefault();
2727

2828
try {
2929
// create an object with the data we want to send to the server
3030
const requestData = {
3131
username: e.target.username.value, // gets the value of the field in the submitted form with name='username'
3232
password: e.target.password.value, // gets the value of the field in the submitted form with name='password',
33-
}
33+
};
3434
// send a POST request with the data to the server api to authenticate
3535
const response = await axios.post(
3636
`${process.env.REACT_APP_BACKEND}/auth/signup`,
3737
requestData
38-
)
38+
);
3939
// store the response data into s the data state variable
40-
console.log(`Server response: ${JSON.stringify(response.data, null, 0)}`)
41-
setResponse(response.data)
40+
console.log(`Server response: ${JSON.stringify(response.data, null, 0)}`);
41+
setResponse(response.data);
4242
} catch (err) {
4343
// request failed... user entered invalid credentials
4444
setErrorMessage(
4545
"The username or password you entered are not valid. Try harder! "
46-
)
46+
);
4747
}
48-
}
48+
};
4949

5050
// if the user is not logged in, show the signup form
5151
if (!response.success)
@@ -74,10 +74,10 @@ const Signup = props => {
7474
</p>
7575
</section>
7676
</div>
77-
)
77+
);
7878
// otherwise, if the user has successfully logged-in, redirect them to a different page
7979
// in this example, we simply redirect to the home page, but a real app would redirect to a page that shows content only available to logged-in users
80-
else return <Navigate to="/" />
81-
}
80+
else return <Navigate to="/" />;
81+
};
8282

83-
export default Signup
83+
export default Signup;

0 commit comments

Comments
 (0)