Error code: src/api/index.js
import Fetch from'../fetch/index' import jk from './ jk ' export default { verifycodeApi: params => Fetch(jk.verifycode, {method:'get' ,body: params}) }
In the get method here, the body is used to accept the parameters, so an error is reported.
solution:
In the packaged fetch.js
const Fetch = (url, option = ()) => { // Format the data of the get request (the get request of fetch needs to splice the parameters behind the url) if (option.method ==='get') { if (option.data) { url = url + formatUrl(option.data) } } // Process non-get request headers and request bodies if (option.method ==='post' || option.method ==='put' || option.method ==='delete' ) { option.headers[ 'Content-Type'] = option.headers['Content-Type'] ||'application/json' option.body = qs.stringify(option.body) // option.body = JSON.stringify( option.body) } delete option.data }
The key point is the code marked in orange. This is to create a data attribute for the get method. After the url is spliced, delete the data attribute with delete.
So, in src/api/index.js
// The api file stores the interface folder import Fetch from'../fetch/index' import jk from './ jk ' export default { manageloginApi: params => Fetch(jk.managelogin, {method:'post' , body: params}), verifycodeApi: params => Fetch(jk.verifycode, {method:'get' , data: params}) }
You can use the data attribute to store the parameters passed by get, avoiding the error of body passing parameters
Read More:
- How to Solve Error: cannot open .Git/fetch_HEAD: Permission denied
- Debug Error: Failed to fetch current robot state [How to Solve]
- [Android] method of removing title bar and using request window feature (Window.FEATURE_ NO_ Title); why does it fail
- [Solved] Nginx Request 500 Error: CreateFile() “/temp/client_body_temp/0000000013” failed (5: Access is denied)
- if a proxy or similar is necessary `net.git-fetch-with-cli`, Rust Complete `Couldn‘t resolve host name (Coul
- [Solved] Axios Error: Request body larger than maxBodyLength limit
- Axios request failed, get the status code and error information, how to encapsulate the function dealing with the public error code
- [Solved] swagger Error: Fetch errorInternal Server Error /swagger/v1/swagger.jso
- How to Solve Error: Android java.lang.IllegalStateException: Could not execute method of the activity
- [Solved] Eureka related services Start Error: cannot execute request on any known server
- JZVideo Error: Attempt to invoke virtual method ‘android.view.Window android.app.Activity.getWindow()’ on a null object reference
- There was an unexpected error (type=Method Not Allowed, status=405). Request
- Springcloud configuration center client 3355 startup Error: error on get request for“ http://localhost:8761/eureka/apps/ “: Connection
- How to Solve Logstash error: failed to execute action
- [Solved] Failed to get convolution algorithm. This is probably because cuDNN failed to initialize
- [Solved] TF2.4 Error: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize
- [Solved] Failed to register: Error: Failed to get admin…. run enrollAdmin.js
- Failed to get convolution algorithm. This is probably because cuDNN failed to initialize,
- Android Phone Record Screen Error: failed to get surface