Y
Y
yativ_sobb2017-07-30 14:50:43
JavaScript
yativ_sobb, 2017-07-30 14:50:43

Axios send post send options?

Sends method post writes options

return this.url.post('/index.php/rest/' + type + '/signup',{
      number,
      name,
      city_id
    })

Request URL:http://ummaadmin.workapp.kz/index.php/rest/user/signup
Request Method:OPTIONS
Status Code:405 Method Not Allowed
Remote Address:212.224.124.72:80
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Host,X-Forwarded-Proto,X-Forwarded-Port,Connection,Access-Control-Request-Method,Origin,User-Agent,Access-Control-Request-Headers,Accept,Referer,Accept-Encoding,Accept-Language
Access-Control-Allow-Methods:POST , GET, DELETE, PUT , OPTIONS
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Sun, 30 Jul 2017 11:44:20 GMT
Server:nginx/1.10.1
Transfer-Encoding:chunked
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:ummaadmin.workapp.kz
Origin:http://localhost:8081
Referer:http://localhost:8081/
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 OPR/46.0.2597.57 (Edition Campaign 34)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-07-30
@yativ_sobb

  • If the method is not GET / POST / HEAD.
    …Any of the conditions above will cause the browser to make two HTTP requests.
    The first request is called "pre-request" (English term "preflight"). The browser does it entirely on its own initiative, we don’t know anything about it from JavaScript, although we can see it in the developer tools.
    This request uses the OPTIONS method. It does not contain a body and contains the name of the desired method in the Access-Control-Request-Method header, and if special headers are added, then these too in Access-Control-Request-Headers.
    Its job is to ask the server if it allows the selected method and headers to be used.
https://learn.javascript.ru/xhr-crossdomain
As you can see, the point is that you didn't specify the Content-Type header.
This request should be followed by a POST request if the server responded that everything is OK (in your case it looks like it).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question