angular-http

Unable to implement PUT request in angular 2 ,getting an error “null values are not allowed”

邮差的信 提交于 2019-12-11 02:25:39
问题 I have implemented GET request in my application and able to fetch data for my Account Table in the AccountComponent . When I click on a particular row in the DataGrid , I get a POPUP window where I can access the row_data and using the dropdowns can update the **DataGrid ** But when I am selecting the required values for the dropdowns and trying to update, I'm getting the following error in my console. Error code is : Error {"message":"Null values are not allowed","error":"java.lang

Angular2 Response for preflight is invalid (redirect) from some GET requests

送分小仙女□ 提交于 2019-12-11 02:07:07
问题 I am using Angular2, Communicating with a rest API, settings the header like so: import { Headers } from '@angular/http'; export const contentHeaders = new Headers(); contentHeaders.append('Accept', 'application/json'); contentHeaders.append('Content-Type', 'application/json'); contentHeaders.append('Authorization', localStorage.getItem('id_token')); Get request like items/ and POST request works, but when making GET requests for one item, like: items/579212a6541d5626732619c3 the server

Angular 4 POST call to php API fails, but GET request work and POST requests work from Postman

让人想犯罪 __ 提交于 2019-12-11 01:59:09
问题 I have an Angular 5 application which connects to an PHP API, everything worked ok when testing in local environment (Ubuntu 16.04, Apache2 2.4.18, PHP 7.2.2) but when I deployed the project in my school server (Uubuntu, Apache2 2.4.27, PHP 7.1.11), GET requests are ok but POST requests are turned into OPTIONS requests and Angular displays the error. ERROR Object { _body: error, status: 0, ok: false, statusText: "", headers: {…}, type: 3, url: null } Request from origin has been blocked from

CORS Issue same controller, one method is ok, other one is not

早过忘川 提交于 2019-12-11 01:45:50
问题 Very strange error I'm experiencing. I have two methods in controller which are called by angular js http get event. First one works fine, second one is throwing CORS error, not sure how is that possible since both of them are in same controller. This is the error I'm getting: These are the calls I'm doing in angularjs: $http({ url: 'http://localhost:52876/api/Admin/GetLoanInfo', method: "GET", params: { loanID: querystringParam } }).success(function (data, status) { console.log(data); $scope

AngularJS and Digest HTTP Authentication

我与影子孤独终老i 提交于 2019-12-10 15:46:00
问题 I am trying to implement the digest auth algorithm in angular. However, the lack of knowledge about the requests angular will send stops me from perceiving that goal. My approach is to transform the request via the $httpProvider.defaults.transformRequest route. But the functions I provide function (data, headersGetter) obviously is not provided with any knowledge about the upcoming request. Since I have no knowledge about the request URI (but especially the method, such as PUT, GET etc.)at

How can I make $httpBackend insensitive to the order of URL query parameters?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 12:30:01
问题 I am using the Angular.js $httpBackend to test some services that wrap $http calls (this is in ngMock, not ngMockE2E). It seems that things like expect and when are sensitive to the order of URL query parameters. E.g. if I do $httpBackend.when('POST','/apiCall?X=1&Y=2').respond(/* ... */) or $httpBackend.expectPOST('/apiCall?X=1&Y=2') , I get URL mismatches if I have Y=2&X=1 in the URL instead of X=1&Y=2 . I want to write my tests in such a way that the service being tested will be free to

Overload request headers and params with HttpClient get

可紊 提交于 2019-12-10 11:04:08
问题 In HttpClientModule, is there a method to pass headers and params to get request. import { HttpHeaders, HttpParams, HttpClient } from @angular/common/http'; const headers = { headers: new HttpHeaders({}) } let params = new HttpParams({ }); get(url, {params}) // http client get with params get(url, {headers}); //http client get with headers I want something like requestoptions to hold both or a syntax to do httpClient get sending request headers and params. Currently building complete url with

Angular $http.get: How to catch all the errors?

爱⌒轻易说出口 提交于 2019-12-10 10:22:28
问题 Im sending a form to nodejs for authentication. Using $http.get in the following function and adding a promise > .then . In production, does this handle all the errors that I may get from the server? Do I need to add anything else to this function? MyApp.controller("Login", function($scope, $http){ $scope.checkuser = function(user){ $http.get('/login', user).then(function(response){ if(response.data){ console.log(response.data); //based on response.data create if else .. } else { console.log(

Angular 2 Http response generic error handler

左心房为你撑大大i 提交于 2019-12-09 05:00:10
问题 I'm implementing an Angular 2 app which will make some API calls. I was wondering if is there anyway to make a generic error handler. For instance, I want to redirect users to the login route if the API responds with a 401 code. Is this posible? Thanks 回答1: I created an http helper method which I use from all my services. That at least centralizes all the http activity through the application. Handling error details is sometimes though - see my question here: Angular 2 http service. Get

Angular >= 4.3, httpClient.get params empty

不想你离开。 提交于 2019-12-09 00:08:26
问题 I'm trying to migrate my Http requests to HttpClient requests. I was able to migrate my post queries but I'm facing a problem while migrating get queries. When I do so, my backend doesn't receive any parameters respectively, it tells me that the parameters are not provided and empty. Did I do something wrong? import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http'; constructor(private httpClient: HttpClient) {} findItems() { let params: HttpParams = new HttpParams(); params