Я отправляю запрос на публикацию с использованием fetch. Я отправляю с помощью jsonbody. Он работает с почтальоном, но не в моем реагирующем коде. Пожалуйста, помогите
Я установил тело запроса в заголовке. Я не знаю, почему яполучение 404 не найдено исключение.
вот мой код
authenticate=(loginid,passw)=>
{
console.log(loginid,passw);
const url ="http://localhost:8443/v2/rest/authenticateuser";
var requestBody={"loginid":loginid,"passw":passw};
console.log(requestBody);
fetch("http://localhost:8443/v2/rest/authenticateuser",
{
method: 'POST',
mode: 'no-cors', // no-cors, cors, *same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
redirect: 'follow', // manual, *follow, error
referrer: 'no-referrer', // no-referrer, *client
body:JSON.stringify(requestBody)
})
.then(res => res.json())
.then(
(result) => {
console.log(result);
this.props.login(result.islogin);
})
.catch((error) => {
this.setState({show:false});
window.alert("error",error);
console.log("authentication failed");
});
}
//handlesubmit as a handler for submit button
handleSubmit = e => {
e.preventDefault();
this.props.manageridupdate(e.target.elements.loginid.value);
this.authenticate(e.target.elements.loginid.value,e.target.elements.passw.value);
};
Я получаю эту ошибку.
POST http://localhost:8443/v2/rest/authenticateuser 404 (Not Found)
App.authenticate @ App.js:19
App.handleSubmit @ App.js:49
callCallback @ react-dom.development.js:147
invokeGuardedCallbackDev @ react-dom.development.js:196
invokeGuardedCallback @ react-dom.development.js:250
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:265
executeDispatch @ react-dom.development.js:571
executeDispatchesInOrder @ react-dom.development.js:596
executeDispatchesAndRelease @ react-dom.development.js:695
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:704
forEachAccumulated @ react-dom.development.js:676
runEventsInBatch @ react-dom.development.js:844
runExtractedEventsInBatch @ react-dom.development.js:852
handleTopLevel @ react-dom.development.js:5029
batchedUpdates$1 @ react-dom.development.js:21463
batchedUpdates @ react-dom.development.js:2247
dispatchEvent @ react-dom.development.js:5109
(anonymous) @ react-dom.development.js:21520
unstable_runWithPriority @ scheduler.development.js:255
interactiveUpdates$1 @ react-dom.development.js:21519
interactiveUpdates @ react-dom.development.js:2268
dispatchInteractiveEvent @ react-dom.development.js:5085