AngularJS tag for $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser's XMLHttpRequest object or via JSONP.

learn more… | top users | synonyms

0
votes
1answer
28 views

get .error with “.then” method in Angular.js [duplicate]

I'm trying to consume a url, through .then angular method. I handle this structure. I want to know how to get such an error when trying to consume the url and I have no internet service, or when there ...
29
votes
4answers
28k views

Error handling in AngularJS http get then construct

How can I handle an HTTP error, e.g. 500, when using the AngularJS "http get then" construct (promises)? $http.get(url).then( function(response) { console.log('get',response) } ) ...
1
vote
2answers
621 views

Ionic. Return factory from data from JSON file

I'm playing around with Ionic sample projects and am looking for a way to pull in the data from a json file rather than just the standard array that is in the project. I have successfully modified ...
0
votes
1answer
45 views

AngularJS, save many inputs into a JSON file

I'm dealing with this since last nigth. The thing is, I'm loading data from a JSON file, it goes perfectly, but now, I would like to add manually the same object to my HTML, I don't even care to save ...
2
votes
3answers
5k views

Getting data from a web service with Angular.js

Im trying to get data in a Json format from a remote WS using Angular and im having some trouble. The data comes from the web service correctly but i cant use it inside the controller. Why is that? ...
2
votes
2answers
9k views

How to read response headers in angularjs?

My server returns this kind of header: Content-Range:0-10/0: I tried to read this header in angular with no luck: var promise = $http.get(url, { params: query }).then(function(response) { ...
1
vote
3answers
26 views

Angular2 @Input and http.get

I'm missing something when passing data from a component to another component. I use @Input to pass the data, that i get from an http.get request. The thing is, i get an error while trying to access ...
1
vote
1answer
42 views

Angular 2 Http – How to Get JSON Data from API with finance_charts_json_callback() callback

I don't really know the terminology here, but I'm trying to get json data from this api: http://chartapi.finance.yahoo.com/instrument/1.0/NFLX/chartdata;type=quote;range=1d/json And I don't know how ...
0
votes
1answer
68 views

Angular2 HTTP: Uncaught SyntaxError: Unexpected token < polyfills

So Im practicing http post and get methods of Angular2 from YouTube tutorial and I cant figure out the problem Here is my index.html files: <html> <head> <title>MyTodo ...
1
vote
1answer
31 views

I need to do a http request to a mail chimp subscription list via a component post

I need to do a http request to a mail chimp subscription list via a component post I've read the mail chimp documentation and couldnt find anything on this. I also tried their mail chimp embedded ...
2
votes
1answer
100 views

Angular 2 http request with Access-Control-Allow-Origin set to *

I'm using angular2 and typescript. I'm trying to post to my mail chimp subscription list. My code so far: constructor(router: Router, http: Http){ this.router = router; this.http = ...
0
votes
1answer
21 views

Angular v1.4.9 $badreq error, failing before interceptor can add url

In patch v1.4.9 Angular added a $badreq error when a $http call has no url param, but in my code if no url is set it is added in my interceptor and pointed at my api. Since it now fails before ...
1
vote
1answer
20 views

How to pass JSON string via Angular $http using a variable instead of function(param)?

I have a JSON object like so: var newContact = {"contact_name":"Joe","contact_cell_phone":"4651354"} And I need to pass it through to C# ASP backend using Angular $http.post such as: $scope.Add = ...
0
votes
2answers
38 views

$http is not a function in link functions of directive

I am new to angular js and trying to use directives. I want to use $http in link function of directive. Below is my code MyApp.directive('appItem', ['$http',function() { return { restrict: ...
0
votes
0answers
39 views

Abort HTTP request when redirect

I got this page which uses Angular and when the page is loaded, it requests some data from a HTTP get call. My problem is that if the user navigates to a other page while the HTTP get call is going ...
0
votes
0answers
22 views

Angular resource use nested property from returned json

I want to use ngResource for some of my resources, the problem is all of my responses are in the following form: { code: 200, data: { the real resource is here } } I want $resource to use ...
0
votes
1answer
1k views

AngularJS: $http service GET to php server: Request Method:OPTIONS, Status Code: 405 Method Not Allowed

I'm struggling with this issue since many hours... :-( My grunt-served angular app issues an $http GET request to a simple PHP service on the same host (apache), to get a list of persons. The result ...
1
vote
2answers
765 views

HTTPS with $http in Angular not working

I'm building a Facebook Tab using Angular. I'm doing a $http request to a PHP page on the same domain. The request looks like this: $http({ method: 'JSONP', url: ...
0
votes
1answer
65 views

How can I post data as form data with Angular

I want to send an avatar to my server but I have this error "You must include 'avatar' file var in your POST form data." function getPictureSuccess(imageData) { var image = ...
0
votes
1answer
27 views

angular encode space as + not %20

I am using angular 1.4.8 and there is bug i thing with encode parameter in get request. This is my service : angular .module('test') .factory('User',User); /* @ngInject */ ...
0
votes
2answers
43 views

Normalising controller in AngularJS

Am pretty new to AngularJS. I have written a code and its working fine. Would like to know, is there a way to further shrink the controller. My index.html file is <!DOCTYPE html> <html ...
0
votes
0answers
20 views

AngularJS: How to use same $http call with $cacheFactory to return json data?

I have to show some data in multiple tabs div using $http call on each div one by one (onclick) using same Restful service. Please Let me know how to cache this using signal method. ...
1
vote
1answer
77 views

angular $http.get error, unexpected token

I was just starting to test a simple API using this code: $http.get('/api/products?limit=10').then(function (response) { console.log(response.status); }); And I get this error: SyntaxError: ...
1
vote
1answer
25 views

AngularJS $resource is encoding entire object into URL

I'm using Angular 1.4.8 with Angular UI and TypeScript. My models are defined as such: export interface IBatch extends ng.resource.IResource<IBatch> { id: Number; ... } export ...
3
votes
3answers
4k views

Use withCredential with $resouce

I want to use resource with a cookie set in the navigator. With $http it is really easy, as I only need to set withCredential to true: $http({ method: 'POST', url: url, data: user, ...
1
vote
2answers
43 views

AngularJs - `$http` works But `$resource` not working - how to apply `$http` params to `$resource`

I am trying to post the image informations to back-end. I tried with $resource but not working. But when i tried with $http it seems that works. But i have added some of additiona params to $http - ...
1
vote
1answer
39 views

sending FormData with angular $http

I'm writing an angular-1.5.0-rc0 application In this application I create FormData, fill it with values and I need to send it with $http request. for now I use jquery ajax with the following code: ...
3
votes
3answers
6k views

Best way to provide url to angular $http.get/.post

I am using angular with MVC4. I would like to call a MVC controller method from javascript using $http.get(). It requires a url (obviously). I would like this to be a relative path, but how do I ...
35
votes
3answers
64k views

Angularjs autocomplete from $http

I'm trying to write an autocomplete directive that fetches data from the server using an $http request (without using any external plugins or scripts). Currently it works only with static data. Now, I ...
0
votes
1answer
110 views

Http call being made twice with parameters reset

I'm making a GET request to retrieve posts, but when I load the page, it makes the first request with the correct page query in the request URL but then immediately makes another request with page set ...
1
vote
1answer
36 views

How to dynamical set de widgetDefinitions in malhar angular dashboard via rest client?

I have installed malhar-angular-dashboard module and I want to populate some widgetDefinitions with my rest data. HTML <div ng-controller="widgetCtrl"> <div ...
177
votes
27answers
258k views

AngularJs $http.post() does not send data

I'm pulling my hair out - could anyone tell me why the following statement does not send the post data to the designated url? The url is called but on the server when I print $_POST - I get an empty ...
0
votes
2answers
113 views

Angular HTTP request blocked - Showing mixed content

Angular HTTP request is blocked - Showing mixed content. But when i'm accessing through browser URL, the content is showing. The angular code is: ...
1
vote
4answers
165 views

$http.get with null parameters are not hitting the Web API controller

I am trying to get to Web API GET controller using $http.get in angular application as follows : $http.get(BasePath + '/api/documentapi/GetDocuments/' , { ...
1
vote
1answer
35 views

Execute code within a factory when needed, not when loaded into controller

Factory: .factory("myFac", ['$http', '$q', function($http, $q) { var defer = $q.defer(); $http.get('some/sample/url').then(function (response) { //success /* * Do ...
1
vote
3answers
78 views

How to make a $http request from the rest client in AngularJs?

Have this scenario when I make a request via $http in the first service, and then I want to manipulate the data in other service. For some reassons my returned object is empty. Any advice ? ...
0
votes
2answers
48 views

Unable to reflect $http response in the view ng-repeat

I have seen other questions relating to this and implemented the answers to the best of my understanding. But, I am unable to display the response in the view with ng-repeat. Here is my code. JS ...
1
vote
2answers
46 views

How can I get the response of an interceptor on my own defined service in Angular.js?

I have an Angular app with a service (EqService), for which I want to know the Timestamp Marker in the asynchronous call. I'm using request and response interceptors. The key components are like so: ...
0
votes
1answer
62 views

How to wait till the response comes from the rest client, in AngularJs?

I have a Rest Service witch returns : {dataRef:Array[3],status:Object}. When I inject the service in the controller and run the application, I still have trouble with returning the data from my rest ...
0
votes
0answers
26 views

Angular $resource vs $http and escaping/encoding parameters

What am I doing wrong. I want to use $resource to do my queries but when I attempt to escape the parameter it doesn't escape properly. But if I use $http.get it will escape correctly. Version of ...
0
votes
0answers
32 views

How to pass parameters from AngularJS to SpringMVC in Nested Object

There are three ng-model in page like this: ng-model="user.addr.location" ng-model="user.addr.number" ng-model="user.name" HTTP request in AngularJS: $http({ url: "/login", method: "POST", ...
1
vote
1answer
39 views

AngularJS $http request to Coursera's REST API. Cross-origin denied although public key is not required

Coursera API documentation: https://tech.coursera.org/app-platform/catalog/ I tried to make a simple GET call to the api: https://api.coursera.org/api/courses.v1 Like This: ...
3
votes
2answers
288 views

Handle Angular $http errors locally with fallback to global error handling

I have a component based Angular application where the individual components load their respective data. When errors occur I generally want the component to display an error message. However, in some ...
0
votes
0answers
36 views

Angular2 failing to read component attribute inside a method

So I have a form where the user enter his credentials. In the onSubmit function I will compare the input values with the stored values . The stored values were read from JSON file in the constructor. ...
1
vote
4answers
94 views

AngularJS catch all status-codes for $http actions?

My $http functions can return the following errors: POST http://foobar.dev/foobar 500 (Internal Server Error) POST http://foobar.dev/foobar 401 (Unauthorized) Isn't there a way I can catch ...
7
votes
1answer
2k views

Reject from 'response' into 'responseError'

Sometimes, the API I'm using will return 200 ok even though there has been an error. The response JSON object will look something like: { error: true } I've built a $http response interceptor ...
1
vote
1answer
76 views

What's the nicest way to wait for a promise initiated on a directive to resolve?

This is a simple form that contains one input field with a directive. If the input is valid, the directive will call a remote server. The response will populate the form model with some extra data. ...
2
votes
0answers
70 views

in $http. What is wrong with this code?

I made a function to do it. getTemplate it called And I call it from templateUrl and I gives him the name of the state I do not understand why it does not work for me, Even it does not make me alert ...
375
votes
20answers
238k views

How can I post data as form data instead of a request payload?

In the code below, the AngularJS $http method calls the URL, and submits the xsrf object as a "Request Payload" (as described in the Chrome debugger network tab). The jQuery $.ajax method does the ...
2
votes
1answer
58 views

How to use ngResource-like query urls with $http

I'm using Angular and I've got to do some not-restful ajax calls. And, because of that I can't use ngResource. My URL are something like /admin/:someId or /admin/:someId/users/:someUserId. The ...