Error details:
Reason: Missing form parameter: grant_type
However, if the parameter is passed and an error is still reported, it means that the passed data format is wrong, and the data format needs to be modified.
Solution:
The first step: set the data format
It is best to set the Content-Type to dynamic, and do not globally modify the encapsulated request to avoid affecting requests from other interfaces.
headers: {
'Content-Type':'application/x-www-form-urlencoded'
},
Step 2: Convert the parameters after the url request address into an object
-
install querystring
npm install querystring
oryarn add querystring
-
import querystring
-
Convert the passed parameter data into an object
data: queryString.stringify(params)