angular-http

Angular 2 : No provider for ConnectionBackend

你离开我真会死。 提交于 2019-11-28 08:56:36
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'; import {Observable} from 'rxjs/Observable'; import {MyService} from './../services/myService' import {Post}

$http.post() method is actally sending a GET

╄→гoц情女王★ 提交于 2019-11-28 07:17:36
问题 NOTE: I've found a possibly related issue that warrants a new question here This is a weird problem. I've been using angular over the course of 2 years and have never run into this problem. I'm using angular v1.5.0. I'm making a post request like this: $http({ method: "POST", url: "/myurl", data: { file: myFile // This is just an object } }); Run-of-the-mill POST request right? Get this. I look in the console and the Network tab logs the request as a GET. Bizarre. So I've jiggered the code to

$http post in Angular.js

巧了我就是萌 提交于 2019-11-28 06:26:53
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 I have so far - function TestController($scope) { $scope.persons = $http({ url: 'http://samedomain.com

Send array via GET request with AngularJS' $http service

帅比萌擦擦* 提交于 2019-11-28 05:40:45
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 issue thanks to Jonathan's suggestion using jQuery's $.param() . $http( method: 'GET' url: '/items?' + $

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

笑着哭i 提交于 2019-11-28 02:23:19
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://mysubscriptionlist.us10.list-manage.com/subscribe/post?u=b0c935d6f51c1f7aaf1edd8ff&id=9d740459d3

Angular 2 Spring Boot Login CORS Problems

走远了吗. 提交于 2019-11-28 00:30:53
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. First thing you need to understand Cors configuration is added in the backend. You do not need to send cors header

$http get parameters does not work

旧城冷巷雨未停 提交于 2019-11-27 17:33:46
Does anyone know why this does not work? $http .get('accept.php', { source: link, category_id: category }) .success(function (data, status) { $scope.info_show = data }); and this does work: $http .get('accept.php?source=' + link + '&category_id=' + category) .success(function (data, status) { $scope.info_show = data }); dnc253 The 2nd parameter in the get call is a config object. You want something like this: $http .get('accept.php', { params: { source: link, category_id: category } }) .success(function (data,status) { $scope.info_show = data }); See the Arguments section of http://docs

How to make an http call every 2 minutes with RXJS?

…衆ロ難τιáo~ 提交于 2019-11-27 14:49:11
I have a service that will make a call to my rest service every 2 minutes. On my service I have the following function getNotifications(token: string) { const body = 'xxxxxxxxx=' + token; return this.http.post('/rest/ssss/ddddddd/notificationcount', body, this.options) .map((res) => res.json()); } On my component I call my service function to call the API. this.notificationService.getNotifications(this.token).subscribe((data) => { console.log(data); }); I want to make this call every 2 minutes, what is the best way to do this? Since you are already using Observables , simply make full use of

Error handling in AngularJS http get then construct

心不动则不痛 提交于 2019-11-27 11:37:58
问题 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) } ) Problem is, for any non 200 HTTP response, the inner function is not called. 回答1: You need to add an additional parameter: $http.get(url).then( function(response) { console.log('get',response) }, function(data) { // Handle error here }) 回答2: You can make this bit more cleaner by using: $http.get(url) .then(function

Angular HTTP: Status -1 and CORS

怎甘沉沦 提交于 2019-11-27 07:54:22
问题 In our angular application sometimes we get http status -1 returned to us. The status -1 happens on a popup that is closed, so the user isn't affected by it, just our logs. I attempted to handle it by doing switch (response.status) { case 0: break; case -1: break; case 401: localStorageService.clearAll(); redirectToUrlAfterLogin.url = $location.path(); $location.path('/login'); Which was suggested in AngularJS Issue #12920 We are definitely getting less logs in, but there are still some HTTP