Problems encountered in koa2 post

Time:2021-4-8

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

Problems encountered in koa2 post

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.

Problems encountered in koa2 post

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

Recommended Today

Third party calls wechat payment interface

Step one: preparation 1. Wechat payment interface can only be called if the developer qualification has been authenticated on wechat open platform, so the first thing is to authenticate. It’s very simple, but wechat will charge 300 yuan for audit 2. Set payment directory Login wechat payment merchant platform( pay.weixin.qq . com) — > Product […]