Unable to issue post request using axios in nuxt

this.$axios.post("url", {})

axios is used in nuxt. It is no problem to send out a get request. As soon as a post request is made, report 404.
as shown in the figure, Method:OPTIONS is shown instead of POST

.
Sep.10,2021

axios post request, but the console checks that it is OPTIONS, not post request


has the backend allowed the OPTIONS method? The GET request is a simple request, and the OPTIONS; post request will not be sent first as a non-simple request. The first OPTIONS, will need the backend to release the OPTIONS method on the interface, or 200 will be returned for the OPTIONS release method. About simple requests and non-simple requests, you can learn about Baidu, or take a look at this article .


if you don't want the first request to be OPTIONS, you can do this
modify header
will

'Content-Type': 'application/json; charset=utf-8',
Change

to

'Content-Type': 'application/x-www-form-urlencoded',

body can be processed by querystring.stringify ()


as mentioned above, first check with the interface party whether the interface is requested with get or post . According to the interface side.


if the server side does not implement the response OPTIONS method, change Content-Type to one of the following three

  • application/x-www-form-urlencoded
  • multipart/form-data
  • text/plain

where text/plain can be used as JSON

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5cfa5-456df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5cfa5-456df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?