Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  handleSubmit(e){
  2.         e.preventDefault();
  3.  
  4.         if (this.state.username == ""){
  5.             return this.addError('Prašome įvesti vartotojo vardą');
  6.         }
  7.         if (this.state.password == ""){
  8.             return this.addError('Prašome įvesti slaptažodį');
  9.         }
  10.  
  11.         fetch(config.server + '/sistemosprieinamumas/prisijungti', {
  12.             method: "POST",
  13.             headers: {
  14.                 "Accept": "application/json",
  15.                 "Content-Type": "application/json"
  16.             },
  17.             body: JSON.stringify({
  18.                 "username": this.state.username,
  19.                 "password": this.state.password
  20.             })
  21.         })
  22.         .then(response => {
  23.             if (response.status == 400){
  24.                 return this.addError('Blogi prisijungimo duomenys');
  25.             }
  26.  
  27.             if (response.status == 200){
  28.                 return response.json();
  29.             }
  30.         })
  31.         .then(response => {
  32.  
  33.         })
  34.  
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement