Tagged Questions
0
votes
2answers
17 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 ...
1
vote
3answers
143 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",
...
0
votes
1answer
45 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: ...
1
vote
1answer
103 views
AngularJS - How to handle promises correctly
I have setup an AngularJS resource:
app.factory('gridData', function($resource) {
var csrf = 'asdf';
return $resource('/my/url/:expID', {expID:'@id'},{
get: ...
0
votes
1answer
35 views
AngularJS: issues creating an API request
I have a scenario in which I have to deal with a misconfigured server, which only understands a stringified JSON. What works with the server is:
var req = JSON.stringify({id: 0, method: ...
0
votes
0answers
100 views
Angular resource dynamic uri
Once I was using $http in calling all my apis' endpoint. But lately I read that using $resource is much more robust or best practice. Now I'm migrating all my $http call to $resource and I got bump on ...
1
vote
1answer
89 views
Why the difference in using common and post for changing the ContentType should affect the request payload / form data?
If I use the following:
a)
angularApp.config(function ($httpProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
...
0
votes
1answer
63 views
How to ensure that angular $resource uses the following angular $http settings?
I am using CakePHP as my backend.
Therefore, if I use $http, I need to have the following:
a) the default config must be
angularApp.config(function ($httpProvider) {
...