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
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
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
how do Vue projects built with Nuxt.js share header and footer files? only files with section contents are placed in the page directory. Navigation bars and footers and every time you jump to a new route, navigation doesn t have to be reloaded. Gods, ...
nuxt 1.4 uses keepAlive, in nuxt, but I find that when the page component is switched, the data in data will be reset and emptied when entering the interface . Is this his bug? if there is a problem with the setting, how can I modify the setting? ...
the packaged scripts are generated dynamically by nuxt. How to mark a global variable so that your business code can tell which command it is? (for example, the interface domain names of different commands are different) ...
ask nuxt.js s vue single file, how to make some vue scripts to be rendered by browser instead of server. if the pull-up load belongs to browser rendering through ajax, how to express the .vue single file in ssr mode. Please, everyone. I m in a hurry...
add components with npm install v-distpicker add vendor: to nuxt.config.js [ axios , v vendor: distressed ] how to write in the vue interface, ask the great gods to save ...
I use the npm run dev command, but I use npm run generate to package and generate the dist folder, and open index.html to find that js is all invalid. When I first met vue, I asked for guidance. ...
I have a configuration file in js format, and I don t want to read the configuration every time I have a request. (what if I configure it in cdn,? (not so good on the server Synchronize in the past) if I am writing a service like golang php c, I will c...
page: structure: index.vue homeindex.vue :homeindex.vuevue-awesome-swiper: ...
the project directory automatically generated by nuxt.js no longer has webpack.config.js, so how to configure things such as scss, less, autoprefixer, and url? ...
I need the js file in plugins or assets to call the mutation method add . How can I call it correctly? ...
I want to use this in asyncData () in the Nuxt.js project it is officially said that this cannot be used in asyncData (), but my business requirement is to send a variable managed by vuex to the server when the page is loaded. The data code is as foll...
this relative module was not found ...
I put the configuration file of axios in plugins axios.js with the following code: import axios from axios import qs from qs const hotName = location.hostname if (hotName === localhost ) { axios.defaults.baseURL = ` xxxx.com api` axios...
.eslintrc.js is configured as follows description: The problem with is plugin:vue essential . If you comment it out, vscode will work properly. npm run dev can run normally and will not report an error of export . Of course, an error ...
No response to interface requests in asyncData api.jsaxiosstatic: I put the request in mounted so that I can request it successfully ...
A new project that has just been completed takes into account the problem of seo after it is launched. It uses prerender-spa-plugin to pre-render the page, but the dynamic routing page can not achieve the rendering effect. More often, the meta informatio...
when users are not logged in, they enter the login page by default, while the login page has a "about us " button. Click to enter the page about us. Click on this.$router.,. Now the problem is to enter the page about us from the login page, refresh and ...
suppose that two modules an and b are defined in vuex, and how can action in SET_USER,a be called if there is a mutations method in b? I try to directly store.commit( SET_USER , user); but the prompt cannot find this mutations,. It seems that the c...
in the website built by nuxt.js, a request is sent in the asyncData method on the home page. The interface address is forwarded with nginx. The background log checks the returned data, but the front end does not receive the returned data. The website ca...
< H1 > the code is as follows < H1 > package.json { "name": "example-hello-world", "dependencies": { "nuxt": "latest" }, "scripts": { "dev": "nuxt", &...