score:3

Accepted answer
loginClick(){

    fetch(variables.API_URL+'login',{
        method:'POST',
        headers:{
            'Accept':'application/json',
            'Content-Type':'application/json'
        },
        body:JSON.stringify({
            name:this.state.name,
            password:this.state.password
        })
    })
    .then(res=>res.json())
    .then((result)=>{
        alert(result);
        history.push('/add');
         
    },(error)=>{
        alert('Faild');
    })
}

Related Query

More Query from same tag