angularjs-http

Is it possible to specify parameter order with Angular's $http service?

ぃ、小莉子 提交于 2019-12-05 20:08:35
In my Angular app, I have a service that utilizes $http to retrieve data from a server. The server endpoint uses HMAC authentication and expects the query string parameters to be in a specific order on the URL. Angular sorts the $http parameters when it builds the URL , so it doesn't seem possible to specify a custom parameter order. Here's an example: this.apiCall = function() { return $http({ method: 'GET', url: 'http://example.com/url/v1/endpoint', params: { 'c': 'cdata', 'a': 'adata', 'b': 'bdata' } }); }; Angular will build the URL as http://example.com/url/v1/endpoint?a=adata&b=bdata&c

Angularjs $http.get does not work

£可爱£侵袭症+ 提交于 2019-12-05 17:13:44
My purpose is to consume a REST web service in AngularJS and I am making some trials right now. Below code is not working and throwing following exception. Can you help me identifty the problem? Thanks in advance. function getUsersFromLocal($scope,$http) { $http.get('http://localhost:8080/people'). success(function(data) { $scope.data = data; }); return data; } Error is: TypeError: Cannot read property 'get' of undefined at getUsersFromLocal. The service is accessible and I tested it through some REST clients. If I understood correctly getUsersFromLocal function is inside controller, basically

With AngularJS, I don't want to set the global $http.defaults.headers.common. Can I send my custom header with each $resource call?

穿精又带淫゛_ 提交于 2019-12-05 13:54:25
I'm calling a back-end server that I cannot control. Currently it's using jQuery ajax like this: return $.ajax({ type: "POST", url: "/api/cases/store", contentType: "application/json", data: JSON.stringify(parameters), headers: { "Authorization": cred } : {} }) // ... etc. I want to convert it to use the $resource service, and got it working doing this $http.defaults.headers.common['Authorization'] = cred; return $resource('/api/cases/store').save(); The only problem is that I'm having to set the global $http service defaults with the auth credentials. I am seeing that you're supposed to be

Angular: $http requests gives -1 status

Deadly 提交于 2019-12-05 09:27:13
A node.js server gives "This is a string". (writeHeader, write( string), end). When performing a $http request, I see that the node.js server is responding and sending the information back. In Angular I perform the following request: angular.module('phoneList'). component('phoneList', { templateUrl: 'phone-list/phone-list.template.html', controller: function PhoneListController($http) { var self = this; $http.get('http://127.0.0.1:8081/echo').then(function(response) { self.data = response.data; }, function(err) { self.error = err; self.status = response.status; self.statusText = response

Getting AngularJS Error: “[$rootScope:inprog] $digest already in progress” without a manual $apply

风格不统一 提交于 2019-12-05 01:25:25
Other posts on this error always include someone trying to $apply without using a safe apply, but that's not the case in my example. My function IS successfully returning the data I requested from the API, but I can't clean this bug and it's driving me nuts. Every time before the .success is called in my $http function I get "Error: [$rootScope:inprog] $digest already in progress" in the console. Below are my controller and service. Thanks! Here's my service including a function to post an $http call with a payload: Services.service( 'CoolService', ['$q', '$rootScope', '$http', 'Auth',

Angular 1.6.3 is not allowing a JSONP request that was allowed in 1.5.8

爷,独闯天下 提交于 2019-12-05 01:22:11
问题 Angular 1.6.3 is not allowing a request that was allowed in 1.5.8 and I am getting this error: $sce:insecurl Processing of a Resource from Untrusted Source Blocked The full error is available here. I would like to upgrade my version of angular to 1.6.3 to get the latest and greatest, but I am dependent on this API. Is there a way for me to mark this as a trusted API or another way to use this API? What is the difference between these two versions that is causing this? Here is the code that I

returning image/jpeg as arraybuffer or blob

点点圈 提交于 2019-12-04 05:55:35
问题 I am currently making a call to my api which returns an image as an image/jpeg . My issue is the when calling the url through javascript angular .factory resource I am getting my array buffer as empty {} . Also, the bytes length is 0. If I make the call to the api url with response type '' or 'text' I do see value of multiple types. What am I missing here? Thank you for your help! JS: .factory("Img", function($resource) { return $resource("http://mypathTo/image/:id", { id: "@id" }, {

How to download a zip file in AngularJS / FilesaverJS [duplicate]

大兔子大兔子 提交于 2019-12-04 05:40:25
问题 This question already has answers here : Binary files corrupted - How to Download Binary Files with AngularJS (2 answers) Closed 2 years ago . i have a service function which return me 3 result files(2 text files, 1 zip file). i want to check the header of the response to see if the file is a zip or a text to set the right configuration to download the file. my controller resolved the promise from my service. if i download a text file -> the file says [object object] .. i have seen in my

Angular 1.6.3 is not allowing a JSONP request that was allowed in 1.5.8

我与影子孤独终老i 提交于 2019-12-03 16:38:07
Angular 1.6.3 is not allowing a request that was allowed in 1.5.8 and I am getting this error: $sce:insecurl Processing of a Resource from Untrusted Source Blocked The full error is available here . I would like to upgrade my version of angular to 1.6.3 to get the latest and greatest, but I am dependent on this API. Is there a way for me to mark this as a trusted API or another way to use this API? What is the difference between these two versions that is causing this? Here is the code that I am trying to run: var app = angular.module('app', []); app.controller('firstController', ['$http',

Getting the response as “data”:null,“status”:-1 when calling web api from AngularJS

笑着哭i 提交于 2019-12-02 22:22:27
问题 I am trying to call Web API GET Method from Angular JS 1.6.0 and getting the following error:- Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"http://localhost:51972/api/video","headers":{"Accept":"application/json, text/plain, / "}},"statusText":""} I am getting the proper JSON response when I call the same GET method from Fiddler 4 and returning JSON Text. Please note