selvi jp

selvi jp

  • NA
  • 323
  • 76.8k

Unhandled Rejection (SyntaxError): Unexpected end of input

May 30 2021 2:25 AM
  1. import React, { Component } from 'react';  
  2. import { Button, Card, CardBody, CardGroup, Col, Container, Form, Input, InputGroup, InputGroupAddon, InputGroupText, Row } from 'reactstrap';  
  3. class ApiLogin extends Component {  
  4.     constructor() {  
  5.         super();  
  6.         this.state = {  
  7.             username: '',  
  8.             Password: ''  
  9.         }  
  10.         this.Password = this.Password.bind(this);  
  11.         this.username = this.username.bind(this);  
  12.         this.login = this.login.bind(this);  
  13.     }  
  14.     username(event) {  
  15.         this.setState({ username: event.target.value })  
  16.     }  
  17.     Password(event) {  
  18.         this.setState({ Password: event.target.value })  
  19.     }  
  20.     login(event) {  
  21.         window.fetch('http://*******', {  
  22.             method: 'post',  
  23.             mode:'no-cors',  
  24.             headers: {  
  25.                 'Access-Control-Allow-Origin':'http:******'    
  26.             },  
  27.             body: JSON.stringify({  
  28.                 username: this.state.username,  
  29.                 Password: this.state.Password  
  30.             })  
  31.         }).then((Response) => Response.json())  
  32.             .then((result) => {  
  33.                 console.log(result);  
  34.                 if (result.Status == 'Invalid')  
  35.                     alert('Invalid User');  
  36.                 else  
  37.                     this.props.history.push("/Dashboard");  
  38.             })  
  39.     }  
  40.     render() {  
  41.         return (  
  42.             <div className="app flex-row align-items-center">  
  43.                 <Container>  
  44.                     <Row className="justify-content-center">  
  45.                         <Col md="" lg="" xl="">  
  46.                             <CardGroup>  
  47.                                 <Card className="p-">  
  48.                                     <CardBody>  
  49.                                         <Form>  
  50.                                             <div   className="mb- pageheading">  
  51.                                                 <div className="col-sm- btn btn-primary">  
  52.                                                     Login  
  53.                              </div>  
  54.                                             </div>  
  55.                                             <InputGroup className="mb-">  
  56.                                                 <Input type="text" onChange={this.username} placeholder="Enter username" />  
  57.                                             </InputGroup>  
  58.                                             <InputGroup className="mb-">  
  59.                                                 <Input type="password" onChange={this.Password} placeholder="Enter Password" />  
  60.                                             </InputGroup>  
  61.                                             <Button onClick={this.login} color="success" block>Login</Button>  
  62.                                         </Form>  
  63.                                     </CardBody>  
  64.                                 </Card>  
  65.                             </CardGroup>  
  66.                         </Col>  
  67.                     </Row>  
  68.                 </Container>  
  69.             </div>  
  70.         );  
  71.     }  
  72. }  
  73. export default ApiLogin;  

Answers (1)