Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) In package.json adaugi "proxy": "http://localhost:5000", -> portu il pui pe care il folosesti tu pt https
- 2) Dai npm start
- 3) Exemplu de request :
- getLoginData = () => {
- const config = {
- mode: "no-cors",
- headers: {
- "Access-Control-Allow-Origin": "*",
- "Access-Control-Allow-Methods": "GET,POST,PUT,DELETE",
- "Content-Type": "application/json"
- },
- withCredentials: true,
- credentials: "same-origin"
- };
- this.setState({ isLoading: true });
- axios
- .post(
- "/api/staff/login",
- {
- Username: this.state.username,
- Password: this.state.password
- },
- config
- )
- .then(response => {
- console.table(response.data);
- this.props.setAuthData(response);
- this.checkLogin();
- this.setState({ isLoading: false });
- })
- .catch(() => {
- console.log("Error");
- this.setState({ isLoading: false });
- this.checkLogin();
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement