Post not working as expected in angularjs

前端 未结 1 422
后悔当初
后悔当初 2021-01-14 02:12

I am using an external api, which works very good in postman but not working when i call from angularjs.

Here is how i call from my angular js

相关标签:
1条回答
  • 2021-01-14 02:20

    Looks like you need to provide additional "Content-Type" header and reformat the data you are sending:

    $http.post('http://api.quickblox.com/users.json', {
        token: '2ba123a8c43664886c66702fb81b779b094cc7b8',
        user: {
            email: email,
            login: email,
            password: password
        }
    }, {
        'Content-Type': 'application/x-www-form-urlencoded'
    })
    .then(function(results) {
        console.log('mid');
    })
    .catch(function(response) {
        console.log('Error', response.status, response.data.errors);
    });
    

    Demo: http://plnkr.co/edit/ishIqko1GHT7IGvXV8ZF?p=preview

    0 讨论(0)
提交回复
热议问题