Recently, I just set up an internal system of the company. Originally, I wanted to use express. Later, I thought about it and tried something new. So I decided to use koa2, but!!! It’s all pits (anyway, I used koa for the first time). Post is a pit (however, it’s still quite simple for koa2 to solve cross domain problems. I use the plug-in to search koa2 CORS PS directly: I use koa2, so I use koa2 CORS). Digression, then back to the front with post value to the server when the problem came
The first problem is that I didn’t pay attention to the post that I used to send data, but the method called by router was changed to get and found 404 error. Later, I reflected that I didn’t respond and just uncommented the commented code.
In a word, the final explanation is as follows:
You can’t read the data in the form data when you send the form to the server by post. Later, the koa body plug-in is used to achieve the perfect result. The usage is the picture above