Tagged Questions
using $http service of angularjs.
0
votes
1answer
9 views
Change an existing $http request interceptor
In my angular app, I have a $http request interceptor called 'authInterceptor' that I create like this:
.factory('authInterceptor', function ($q, $window, EXT_API_BASE, $injector) {
return {
...
0
votes
0answers
25 views
Angularjs issue in relacing Ajax request with promises in service
For my Angularjs application in services I have used Ajax call to get the data and is as follows :
var originalRequest = $.ajax({
async : false,
url : ...
0
votes
1answer
21 views
$http response returns the entire index.html
I have site.com.
Each request is redirected here (so 'site.com/book', 'site.com/settings' ecc.. point to 'site.com')
Then I have site.com/api/ where 'site.com/api/user', 'site.com/api/library/' ...
0
votes
1answer
24 views
$http not working. No errors are returned in console
I'm making a mobile app and I have a controller that handles user login. It makes a http call (currently to localhost) to check if the user is valid. For some reason it won't fire off the $http call ...
0
votes
1answer
23 views
ng-class and value load using $http
I've got partial view with one element which class should depend on value of variable in $scope:
<a class="btn" ng-class="{'btn-success': led == 'on'}" ng-click="toggleLed()">On</a>
...
4
votes
2answers
97 views
+100
expectHEAD is documented but not implemented?
In our internal angularjs project, one of the services has $http.head() call which I'm trying to test.
For testing, I'm using Fake HTTP backend provided by angular-mocks. Here is the relevant code:
...
0
votes
2answers
36 views
Why not available $scope.value of the variable in runtime?
Why not available $scope.reserved of the variable in runtime? In template {{reserved}} is ок, but in controller value = undefibed.
I have the following code
Service:
'use sctict'
...
0
votes
1answer
32 views
How to securely set authorization header using angularJs?
It is common to authenticate to web services using an authorization header which contains a secret token. And since the security of this mechanism depends on the token to be secret care should be ...
0
votes
0answers
78 views
angularjs sending cross origin POST to a Ruby on Rails create method
None of the other questions about this seemed to give a descriptive question and/or receive a thorough answer.
Scenario
Use angular to send cross-origin JSON post data to rails create method.
Code
...
0
votes
2answers
38 views
angularjs $http.put changes my URL
I was trying to make a $http.put request with angularjs.
What I do is just:
$http.put("http://mi-url/personalized_product_custom_pages/2")
What it really does is a request to:
...
1
vote
2answers
44 views
Angularjs http basic auth with username and password for Pivotal Tracker api
I'm trying to develop an application to get the Pivotal Tracker stories. First of all I need to do basic authentication to get my Pivotal Tracker token.
Using PHP cURL, I'm doing like this,
curl -X ...
0
votes
0answers
22 views
How to cancel an intercepted $http request in angular based on its httpConfig info?
I am using angular-http-auth package that is an HTTP interceptor for angular that detects 401 Non-Authorized requests and allows to delay request and perform authorization before it.
However, I have ...
0
votes
1answer
20 views
AngularJs pendant for jQuery.active
I'm having timing issues when writing a selenium test for an angular app. There are pending $http requests that need finished before the next step gets executed.
If I would use jQuery, I could do the ...
0
votes
2answers
42 views
AngularJS $http.get cache not working
After next(Route) to other page, come back it still call back the link.
How to cache JSON data from http call to optimize performance?
Try some solution but not working
$http.get(url, { cache: ...
0
votes
0answers
84 views
AngularJS How do I make sequential $http calls to access more data?
For the AngularJS $http service,
How do I loop $http calls in order to access sequential data, while each call needs the previous return data to be used in the next call?
I want to make sequential ...
0
votes
1answer
42 views
The ui router resolve result data is not injected in the controller
In my SchoolyearController the parameter schoolyears is undefined.
How can I retrieve my schoolyears objects in the schoolyearService and inject the result into the SchoolyearController?
SERVICE
...
0
votes
2answers
55 views
Building a '$resource' service for multiple API calls
I have created a factory service that can get data from an API with the following code.
app.factory('Book', ['$resource','$http', function($resource, $http) {
return ...
2
votes
2answers
48 views
angular JS difference between these two ways of calling a web service method
Doesn't matter whether I am posting or deleting etc.. I would write this:
$http({
method: ''
url: '',
data: '',
headers: ''
}).success(function(data, status, headers, config) {
...
0
votes
1answer
136 views
POST 404 Not found.. Angular js
here i'm sending data through $http.post to data/user.php
app.factory('loginService',function($http){
return{
login:function(data,scope){
var ...
5
votes
1answer
96 views
Authenticating angular to get and post on MVC4 site using Windows Authentication
I am currently developing a website using AngularJS, the application is ment to post and get data to and from an already running MVC4 application. This MVC4 application is using Windows ...
0
votes
1answer
47 views
How to $http.post with payload in data?
How do I post data from a form in AngularJS?
<form data-ng-submit="doSomething()">
<input type="text" data-ng-input="do_obj.text"/>
<input type="email" ...
0
votes
2answers
600 views
AngularJS - Send $http GET request with associative array params
with this code I am trying to send a $http.get request to my rest service:
$http({
method: 'GET',
url: '/api/item/all',
params: {
query: {
userid: 7
},
...
0
votes
2answers
130 views
Abort AngularJS $http request, deeply nested in multiple service calls
I'm using a deferred promise to abort a $http request (like explained in this post).
However, I'm unsure of how I should propagate the abort() function added at the root level. Everytime I call ...
0
votes
2answers
230 views
How to mock an angular $http call and return a promise object that behaves like $http
Is there a way to return an HttpPromise (or something similar) to mimic a call to $http? I want to set a global variable that indicates whether the real HTTP request is made or whether a fake ...
0
votes
2answers
60 views
Pass $http from Controller to Directive
I need to use $http.get to grab a json file in my controller:
module.controller 'SampleMapController', ($http, $scope) ->
$http.get('../../highcharts/mapdata/world.geo.json').
success ...
0
votes
0answers
36 views
Receive JSON data using Angular $http get [duplicate]
I'm calling an asmx web method using AngularJS $http get. It's working fine and returning data. But how can i get the data as json instead of xml.
Here is asmx method:
public class DataService : ...
1
vote
1answer
35 views
Getting html as response instead of the object returned from asmx service
I'm trying to call asmx service using AngularJS $http. But i'm unable to get data from web service. I'm getting a success callback, but the response is the entire html page instead of the object ...
0
votes
1answer
186 views
Testing Angular http interceptor
I need to make my application log a user in with saved credentials and retry a request on a 401 and I'm having a hard time testing it because I need the initial call to return a 401, but then return a ...
0
votes
1answer
131 views
$filter is not a function AngularJS
app.controller('myController', ['$scope', '$http', '$filter', function($scope, $http, $filter) {
The above is an example of my code where I am trying to use $http.get and also $filter inside my ...
0
votes
1answer
41 views
angularjs jsonp request fails
I'm trying to do a jsonp request to a server.
However, I don't seem to get it to work at all...
What I've been trying is to request it using this code:
var deferred = $q.defer();
$http({
...
0
votes
1answer
288 views
ng-class class name which contains a scope variable rendered as null
I have a which utilizes classes based on a particular scope variable.
In this case, the scope variable is {{jobSingle.UserFit.Summary.score}} which takes on the values of -1 (when unknown) or 0-10 ...
0
votes
2answers
81 views
How to configure Angular.js to user default host?
For example, I have this call:
$http({method: 'GET', url: '/someUrl'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is ...
0
votes
2answers
138 views
angularjs - can't display json data on a specific page
I'm trying to load data from JSON-file and displaying in my mobile app. But the problem is that I can't display the JSON datas on member-detail.html, where should be displayed datas of a specific ...
0
votes
1answer
89 views
How to get different controllers to use different configurations of $httpProvider in AngularJS?
I have a AngularJS project using the directory layout from angular-seed.
https://github.com/angular/angular-seed
app.js contains the configuration of my http provider. All my controllers have to use ...
0
votes
1answer
264 views
AngularJS $http success but not working
i'm using angularJS and SLIM PHP restful server, the PHP service is working and actually i have already used $http.get() with no problems in this application ...
But now a strange thing is happening, ...
6
votes
2answers
3k views
Using success/error/finally/catch with Promises in AngularJS
I'm using $http in AngularJs, and I'm not sure on how to use the returned promise and to handle errors. I have this code:
$http.get(url)
.success(function (data) {
// Handle data
})
...
0
votes
1answer
544 views
AngularJS controller scope won't sync with promise
I've picked up a project and I'm trying to return some data from a service to my controller. I've been at this for about 12 hours, and have tried different methods. They all usually result in this ...
0
votes
1answer
685 views
$http error handling in angular
$http in my angular project not able to recognize 40X(401,403,405...) errors on iOS.
I am using 1.2.10 angular version and Cordova version 3.4.0.
Below is the code I am using:
...
1
vote
2answers
135 views
Angularjs stubbed development - $http call along with $httpBackend
I am doing stubbed development using angularjs. My stubs are JSON files on the server. So, I am making $http calls within the "stub" function to get the stubs. However as $http is asynchronous, the ...
1
vote
0answers
225 views
AngularJS 1.2 $http seems to cache POST requests when no data is passed
I'm having an issue with AngularJS 1.2 POST requests using $http service.
On a button click, I trigger a POST request like so:
$http.post('my/url').success(function(responseText) {
// Do ...
0
votes
1answer
35 views
AngularJS weird CORS issues depending on method calling POST
Quite simply! Why does this NOT work:
$http.post(apiUrl + '/some/url/blah', {params: data, withCredentials: true})
.then(function(result){
//success!
});
Yet this DOES!!
...
0
votes
1answer
311 views
Angular Js - set token on header default
Im trying to add a header with my access token to each API call. It works well for all the GET requests, but as soon as I try to make a POST the header isn't added.
Here is how I add the token:
...
1
vote
1answer
158 views
Pass multiple parameters to $http.post?
I am trying to do a post request to save data in the server using the following url:
url = /api/projects/:projectId/scenarios/:scenarioId
I want to pass projectId and scenarioId. How can I do that ...
2
votes
1answer
258 views
How can we test non-scope angular controller methods?
We have few methods in Angular Controller, which are not on the scope variable.
Is anyone know, how can we execute or call those methods inside jasmine test?
Here is main code.
var testController ...
1
vote
3answers
247 views
With AngularJS, I don't want to set the global $http.defaults.headers.common. Can I send my custom header with each $resource call?
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",
...
2
votes
1answer
1k views
AngularJS API call error with $http GET
I'm trying to create a simple app using Angular that will consume my API. I'm using a VM to run the code, and I access it on my computer, so to call the API from my machine I can use cURL or any other ...
0
votes
0answers
328 views
Sending HTTP Post with multiple data through AngularJS
I am using AngularJS. I would like to send multiple data in a HTTP post through AngularJS. The backend runs Cakephp and I have verified that the Rest API works through python HTTP-post.
I have this ...
1
vote
1answer
85 views
How to add headers to $http for only certain domains
Is it possible to set a header only for specified domains?
The "normal" way of doing this adds that header for all calls, even calls that retrieve HTML templates for example.
...
0
votes
1answer
94 views
How to invalidate $http call with cache:true when header changes
I'm fetching a remote resource and caching the result:
$http({
method:'GET',
cache:true,
url:'...'
});
This works fine. However, when the user changes the languge in the UI, I also ...
0
votes
1answer
64 views
AngularJS: Unexpected undefined in chained results
I've come across this issue before with nested directives, but I managed to find a workaround there. I have code that looks a bit like,
var token = API.callGeneric({}, {method: ...