I
I
Ilya2015-12-30 03:16:55
Angular
Ilya, 2015-12-30 03:16:55

How to make a post request in angularjs?

I make a request on click:

$scope.sentPhoto = function() {
      var data = {id_user: '31'};
      $http.post('http://site/api/v1/messages/index', data)
      .success(function(data)
      {
        console.log(data);
      });
    };

But the response from the server:
028828bddacd4270bd95e4975b4741df.png
I don't understand what's the problem? There is definitely a method on the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2015-12-30
@ArtMavir

The application and the target API are on different domains, so the browser uses a CORS policy to make requests, which instructs the browser to send an OPTIONS request before the POST request, which your server is not trained to handle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question