Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restAngular using method customPOST. text:[object%20Object] is getting added on to the end of URL

The goal I'm trying to accomplish is doing a post in restAngular. I keep trying the code below, but I receive a status code 400 with a customPost. This is the URL I send my request to...http://localhost/api/api/index.php/auth/token/[object%20Object]. As you can see [object%20Object] is gettting added on. How do I get rid of this? Should I be doing another method besides a customPOST? Why is this getting added on?

  var login = Restangular.one('auth/token').customPOST(
    {grant_type:"password", username:"[email protected]",password:"666666",scope:"app"},{},{},
    {Authorization:'Basic ' + client,
    ContentType:'application/x-www-form-urlencoded'});
like image 618
raging_subs Avatar asked Feb 14 '23 18:02

raging_subs


1 Answers

The second argument to customPOST should be a string representing the path. Try this instead:

var login = Restangular.one('auth/token').customPOST(
    {grant_type:'password', username:'[email protected]', password:'666666', scope:'app'},
    '',
    {},
    {
        Authorization:'Basic ' + client,
        ContentType:'application/x-www-form-urlencoded'
    }
);

Or this:

var login = Restangular.one('auth').customPOST(
    {grant_type:'password', username:'[email protected]', password:'666666', scope:'app'},
    'token',
    {},
    {
        Authorization:'Basic ' + client,
        ContentType:'application/x-www-form-urlencoded'
    }
);
like image 56
Jedidiah Hurt Avatar answered Feb 23 '23 00:02

Jedidiah Hurt