Added initial test http request

This commit is contained in:
Finn Kempers 2017-04-27 22:50:11 +01:00
parent f3cc47396f
commit 66b3cd6ea4
3 changed files with 19 additions and 7 deletions

View file

@ -25,15 +25,15 @@
"@angular/platform-browser-dynamic": "4.0.3", "@angular/platform-browser-dynamic": "4.0.3",
"@angular/router": "4.0.3", "@angular/router": "4.0.3",
"@angular/upgrade": "4.0.3", "@angular/upgrade": "4.0.3",
"angular-in-memory-web-api": "^0.3.1",
"chart.js": "2.5.0",
"core-js": "2.4.1", "core-js": "2.4.1",
"moment": "2.18.1",
"ng2-charts": "1.5.0",
"ngx-bootstrap": "1.6.6",
"rxjs": "5.3.0", "rxjs": "5.3.0",
"ts-helpers": "1.1.2", "ts-helpers": "1.1.2",
"zone.js": "0.8.8", "zone.js": "0.8.8"
"chart.js": "2.5.0",
"ngx-bootstrap": "1.6.6",
"ng2-charts": "1.5.0",
"moment": "2.18.1"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "1.0.0", "@angular/cli": "1.0.0",

View file

@ -1,6 +1,7 @@
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { LocationStrategy, HashLocationStrategy } from '@angular/common'; import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
@ -23,6 +24,7 @@ import { SimpleLayoutComponent } from './layouts/simple-layout.component';
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule, AppRoutingModule,
HttpModule,
BsDropdownModule.forRoot(), BsDropdownModule.forRoot(),
TabsModule.forRoot(), TabsModule.forRoot(),
ChartsModule ChartsModule

View file

@ -1,10 +1,20 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map'
@Component({ @Component({
templateUrl: 'register.component.html' templateUrl: 'register.component.html'
}) })
export class RegisterComponent { export class RegisterComponent {
private apiurl="https://dev.app.peartrade.org/api"
constructor(private http: Http) {
this.getAges().subscribe(
result => {console.log(result)}
) }
getAges() {
return this.http.get(this.apiurl +'/info/ages' ).map((response: Response) => response.json());
}
constructor() { }
} }