Skip to content Skip to sidebar Skip to footer

Angularjs Not Allowing Square Brackets In The Url Parameter - '['

I want to call and external api It is working fine if i have parameters like this $http.post('http://api.myprivatebox.com/users.json', { email : email, password : password}).then

Solution 1:

You could set the key by index notation of array as you want to set user['token'] dynamically

Code

var formData = { email : email, password : password};

formData[user['token']] = token; //assuming user & token object has already defined//user[token] : token

$http.post('http://api.myprivatebox.com/users.json', formData).then(function(results) {
    console.log('mid');
});

Solution 2:

user[token] is no a valid key. You have to wrap it in quotes!

Try "user[token]"

Post a Comment for "Angularjs Not Allowing Square Brackets In The Url Parameter - '['"