angular-http

Accessing API with $http POST Content-Type application/x-www-form-urlencoded

假如想象 提交于 2019-11-27 07:26:26
问题 I am trying to access this REST API, which accepts three parameters: stationId , crusherId , monthYear I am doing it like this in AngularJS as: $http({ //headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}, //headers: {'Content-Type': 'application/json; charset=UTF-8'}, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept': 'application/json' }, url: 'https://myurl../api/getHPData', method: 'POST', data: { stationId: 263, crusherId:

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

烂漫一生 提交于 2019-11-27 04:54:02
问题 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 form in an angular 2 html5 view but that doesnt work for some weird reason. So I've resulted to doing a http request to the subscribe list instead and I'm having trouble getting that working. I'm using typescript, angular2 and mail chimp This is my code so far: subscribe = () => { var url = "https:/

Accessing custom http response headers in angularjs

醉酒当歌 提交于 2019-11-27 03:29:25
问题 I am trying to access the header 'error-detail' as you can see in the browser network inspector (link above), the header gets returned. Server-wise I have also added the custom header to the 'Access-Control-Expose-Headers' to allow cross-domain requests as this was suggested to be the fix on other questions. Below is the request to the server along with the success/error callbacks. this.signon = function (request, onComplete, onError) { console.log("Calling server with 'login' request...");

Angularjs autocomplete from $http

喜你入骨 提交于 2019-11-27 02:45:16
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 know that I need to insert my $http request into the source: of the directive, but I can't find any good documentation on the subject. http request $http.post($scope.url, { "command": "list category() names"}). success(function(data, status) { $scope.status = status; $scope.names = data; }) . error(function(data, status) { $scope.data = data || "Request failed"; $scope.status = status; });

Angular 2 : No provider for ConnectionBackend

隐身守侯 提交于 2019-11-27 02:38:13
问题 Get this "No provider for ConnectionBackend!" error when trying to use http with a promise. main.ts // ... tl;dr import a bunch of stuff platformBrowserDynamic().bootstrapModule(MyModule); myModule.ts // ... tl;dr import a bunch of stuff @NgModule({ declarations: [ PostComponent ], providers: [ Actions, MyService, Http ], imports: [ ... ], bootstrap: [MyComponent] }) myComponent.ts import { Component, OnInit } from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router';

$http post in Angular.js

冷暖自知 提交于 2019-11-27 01:22:24
问题 I've just started learning Angular.js. How do I re-write the following code in Angular.js? var postData = "<RequestInfo> " + "<Event>GetPersons</Event> " + "</RequestInfo>"; var req = new XMLHttpRequest(); req.onreadystatechange = function () { if (req.readyState == 4 || req.readyState == "complete") { if (req.status == 200) { console.log(req.responseText); } } }; try { req.open('POST', 'http://samedomain.com/GetPersons', false); req.send(postData); } catch (e) { console.log(e); } Here's what

Send array via GET request with AngularJS' $http service

一曲冷凌霜 提交于 2019-11-27 01:00:05
问题 I need to send a GET request using the $http service. One of the parameters will be an array of ids. The url looks like this one mysite.com/items?id[]=1&id[]=2&id[]=3&id[]=4 I tried this approach $http( method: 'GET', url: '/items', params: { id: ids // ids is [1, 2, 3, 4] } ) but the url I obain is mysite.com/items?id=%5B%221%22%2C%222%22%2C%223%22%2C%224%22%5D That's Because Angular is converting my value in a JSON string. Is there a way to get the behavior I want? [Update] I solved the

Angular 2 Spring Boot Login CORS Problems

人走茶凉 提交于 2019-11-26 21:43:51
问题 I am trying to develop an application with Spring Boot for the back end and Angular 2 for the front end. Actually i have connection problems, when i accessing on the mvc login page from spring. I get following Problems: ( Console ) ( Angular 2 Code ) Spring Code I have set a global Cors Configuration for the FrontEnd port. My Request returns with the Response status 200. But i cant access the Response because i getting the error message in the Console. Spring dosnt have errors. 回答1: First

How to read response headers in angularjs?

ぐ巨炮叔叔 提交于 2019-11-26 20:24:25
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) { console.log(response.headers()); return response.data; }); which just prints Object {content-type: "application/json; charset=utf-8"} Any ideas how to access the content range header? Use the headers variable in success and error callbacks From documentation . $http.get('/someUrl'). success(function(data, status, headers, config) { // this callback will be called asynchronously // when the response is

Angular 4.3 - HttpClient set params

自作多情 提交于 2019-11-26 19:45:10
let httpParams = new HttpParams().set('aaa', '111'); httpParams.set('bbb', '222'); Why this doesn't work? It only set the 'aaa' and NOT the 'bbb' Also, I have an object { aaa: 111, bbb: 222 } How can I set all the values without looping? UPDATE (this seems to work, but how can avoid the loop?) let httpParams = new HttpParams(); Object.keys(data).forEach(function (key) { httpParams = httpParams.append(key, data[key]); }); Before 5.0.0-beta.6 let httpParams = new HttpParams(); Object.keys(data).forEach(function (key) { httpParams = httpParams.append(key, data[key]); }); Since 5.0.0-beta.6 Since