Reactjs 如何修复';表格';已指定值,但从未在axios中使用

Reactjs 如何修复';表格';已指定值,但从未在axios中使用,reactjs,typescript,express,axios,nodemailer,Reactjs,Typescript,Express,Axios,Nodemailer,我在使用localhost上前端的React with axios和后端的Express with NodeEmailer时遇到问题。预期结果是,当我单击“提交”按钮时,我应该会收到电子邮件,但当我单击它时,网站会刷新,URL会更改为:http://localhost:3000/?email=test%40gmail.com&message=fdsfd如果我通过test@gmail.com在电子邮件字段中,该电子邮件未收到 我的前端包含App.tsx文件(我使用reactstrap进行样式设置)

我在使用localhost上前端的React with axios和后端的Express with NodeEmailer时遇到问题。预期结果是,当我单击“提交”按钮时,我应该会收到电子邮件,但当我单击它时,网站会刷新,URL会更改为:
http://localhost:3000/?email=test%40gmail.com&message=fdsfd
如果我通过
test@gmail.com
电子邮件
字段中,该电子邮件未收到

我的前端包含App.tsx文件(我使用reactstrap进行样式设置):

app启动后终端的输出如下:

yarn run v1.17.3
$ concurrently --kill-others-on-fail "yarn backend" "yarn frontend"
$ nodemon backend/dist/index.js
$ cd frontend && yarn start
[0] [nodemon] 1.19.1
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching: *.*
[0] [nodemon] starting `node backend/dist/index.js`
$ react-scripts start
[0] Server listening on port 5000
[1] Starting the development server...
[1] 
[1] Compiled with warnings.
[1] 
[1] ./src/App.tsx
[1]   Line 25:  'form' is assigned a value but never used  @typescript-eslint/no-unused-vars
[1] 
[1] Search for the keywords to learn more about each warning.
[1] To ignore, add // eslint-disable-next-line to the line before.

单击“提交”后,可以更改哪些内容以接收电子邮件?似乎从未使用过使用axios定义的表单,但我不知道如何修复它。这是我在StackOverflow上的第一篇文章。提前感谢。

这只是一个
警告
,因为这一行

const form = await axios.post("/api/form", {
      email,
      message
});
在这里,您已将
axios
调用的返回分配给
form
变量,但从未使用过它。你只需要把它去掉

await axios.post("/api/form", {
      email,
      message
});
或者您可以将其仅用于
控制台.log

const form = await axios.post("/api/form", {
      email,
      message
});

console.log(form); //check here

谢谢你的回复。我不再收到警告,但我忘了补充一点,主要问题是我在单击“提交”后没有收到电子邮件。我会编辑这篇文章。很抱歉给您带来不便。我认为您应该为此提出一个新问题。查看路由处理程序,您通常不应该做的一件事是在路由处理程序中实例化transporter对象。从
createTransport
方法创建的transporter对象至少应该在模块顶部定义,在路由处理程序之外,如果不是在单独的模块中,则可以处理对它的直接访问,以便在服务器上抽象使用。这可能是问题的一部分
const form = await axios.post("/api/form", {
      email,
      message
});
await axios.post("/api/form", {
      email,
      message
});
const form = await axios.post("/api/form", {
      email,
      message
});

console.log(form); //check here