也许我只是在寻找错误的方法,但是在条件中使用事实和变量的正确方法是什么? 如:
handleSubmit = async e => {
e.preventDefault();
var request = JSON.stringify({
drug: this.state.drug,
disease: this.state.disease,
type: this.state.type
});
var xmlRequest = js2xmlparser.parse("request", request);
const response = await fetch('/api/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: request
});
const body = await response.text();
this.setState({
responseToPost: body
});
}
?