import React from "react";
// class Car {
// constructor(name) {
// this.brand = name;
// }
// Present() {
// return 'I have a ' + this.brand +' Car In My Home';
// }
// }
// class Model extends Car
// {
// constructor(name,mod){
// super(name);
// this.model=mod;
// }
// show(){
// return this.Present() + ',it is a ' +this.model
// }
// }
// class Header{
// constructor(){
// this.color="Red";
// }
// ChangeColor=function() {
// document.getElementById("demo").innerHTML +=this;
// }
class Header extends React.Component {
constructor(props)
{
super(props);
this.state={
response:[]
}
}
// postData(url = '', data = {}) {
// // Default options are marked with *
// const response = fetch(url, {
// method: 'POST', // *GET, POST, PUT, DELETE, etc.
// mode: 'cors', // no-cors, *cors, same-origin
// cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
// credentials: 'same-origin', // include, *same-origin, omit
// headers: {
// 'Content-Type': 'application/json'
// // 'Content-Type': 'application/x-www-form-urlencoded',
// },
// redirect: 'follow', // manual, *follow, error
// referrerPolicy: 'no-referrer', // no-referrer, *client
// body: JSON.stringify(data) // body data type must match "Content-Type" header
// });
// return response.json(); // parses JSON response into native JavaScript objects
// }
componentDidMount(){
fetch("http://is-S2130:5000/api/MoveJobtoWms/UpdatingActivityDetail",{
method:'POST',
mode:'cors',
cache:'no-cache',
credentials:'same-origin',
headers:{
'Content-Type':'application/json'
},
redirect:'follow',
referrerPolicy:'no-referrer',
body:JSON.stringify({id:1})
})
.then(res=>res.json())
.then(
(result)=>{
this.setState({
response:result
});
},
(error)=>{
this.setState({
response:error
});
}
)
}
render() {
return (
<div>
<h1>Enter the ID</h1>
<input type="text" id="id" placeholder="Enter ID"></input>
<input type="button" id="btnsubmit" value="Submit" ></input>
<div>{this.state.response.is_success}</div>
<div>{this.state.response.data}</div>
<div>{this.state.response.message}</div>
</div>
);
}
}
export default Header;
Comments
Post a Comment