Hi, i need to do an http request to retreive json, but i have 401 error, because i don’t know how to pass properly the credentials. Any help please?? this is a VPN
Check $http manual first, in looks like u have mistake in request object for $http, also u should know how ur backend works(get, post, put and etc) and choose right one, for example for post it will lool like: var req = { method: 'post', url: 'www.somebackend.com/post', data: [username:'TestUser', password: 'testuserspassword'], }; $http(req).then(function(response){ /*success callback*/ }, function(response){ /* error callback*/ });
Mb i dont get the idia but first of all dont use success,error functions, use then nad there the variabale is response object that will be parsed data field where u will have data form request, i dont need to stringify it, if u whant just look through it u can write something like: .then(function(response){ var data = response.data; for(var i in data) { console.log(data[i]): } });
So for lits i think you should use ng-repeat over ur data, for writing the database its the same like reading from backend, you just need to know what requests u need to perfom and what data its requered.