【问题标题】:Unable to get data from React App to Node server无法从 React App 获取数据到 Node 服务器
【发布时间】:2022-12-04 13:49:35
【问题描述】:

So Am unable to make a search function i want to get a variable from search field and show the results that matched but am constantly getting this error

POST http://localhost:4200/search/ 404 (Not Found)

const [name, setname] = useState(\"\")
  async function postName(e) {
        e.preventDefault()
        try {
            await axios.post(\"/search/\", {
                name
            })
        } catch (error) {
            console.error(error)
        }
    }

app.get(`/search/`, (req, res) => {
    
    var {name} =req.body
    var Desc = {name}
    var Op= Desc+\'%\'
    const q = \"SELECT * FROM taric where Description LIKE ? \";
    con.query(q,[Op], (err, search) => {
      if (err) {
        console.log(err);
        return res.json(err);
      }
      return res.json(search);
    });
  });

    标签: node.js reactjs axios


    【解决方案1】:
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 2023-01-09
    • 2018-09-18
    • 2021-10-12
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    • 2019-09-30
    • 1970-01-01
    相关资源
    最近更新 更多