Angular JS POST request not sending JSON data

前端 未结 7 1699
忘掉有多难
忘掉有多难 2020-12-01 10:30

I am trying to send an object as JSON to my webservice in Flask that is expecting JSON in the request data.

I have tested the service manually by sending JSON data a

7条回答
  •  有刺的猬
    2020-12-01 10:56

    $http({
        url: '/api/user',
        method: "POST",
        data: angular.toJson(yourData)
    }).success(function (data, status, headers, config) {
        $scope.users = data.users;
    }).error(function (data, status, headers, config) {
        $scope.status = status + ' ' + headers;
    });
    

提交回复
热议问题