Javascript 我怎样才能删除“;net::ERR“u NAME”未“u RESOLVED”吗;? 帖子http://localhost3001/register net::错误名称未解析 未捕获(承诺中)错误:网络错误 在createError(createError.js:16) 位于XMLHttpRequest.handleError(xhr.js:84)
URL的格式似乎不正确。这应该起作用:Javascript 我怎样才能删除“;net::ERR“u NAME”未“u RESOLVED”吗;? 帖子http://localhost3001/register net::错误名称未解析 未捕获(承诺中)错误:网络错误 在createError(createError.js:16) 位于XMLHttpRequest.handleError(xhr.js:84),javascript,html,node.js,reactjs,express,Javascript,Html,Node.js,Reactjs,Express,URL的格式似乎不正确。这应该起作用: import Axios from 'axios'; import './App.css'; function App() { const [userNameReg, setUserNameReg] = useState('') const [passwordReg, setPasswordReg] = useState('') const register = () =>{ Axios.post("http:
import Axios from 'axios';
import './App.css';
function App() {
const [userNameReg, setUserNameReg] = useState('')
const [passwordReg, setPasswordReg] = useState('')
const register = () =>{
Axios.post("http://localhost3001/register", {
username : userNameReg,
password : passwordReg,
}).then((res) =>{
console.log(res);
});
};
似乎你在url中缺少“:” Axios.post(“http://localhost3001/register“{ 应该是 Axios.post(“http://localhost:3001/register“{
谢谢。它工作正常。但数据不会进入数据库。谢谢。它工作正常。但数据不会进入数据库。如果您成功获得API响应,那么您需要在后端查看这些内容。@ThanukshiWickramasinghe
import Axios from 'axios';
import './App.css';
function App() {
const [userNameReg, setUserNameReg] = useState('')
const [passwordReg, setPasswordReg] = useState('')
const register = () =>{
Axios.post("http://localhost:3001/register", {
username : userNameReg,
password : passwordReg,
}).then((res) =>{
console.log(res);
});
};
};