Skip to content

Instantly share code, notes, and snippets.

@mhartington
Last active August 25, 2016 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhartington/e61d68aca91215528a95a61cd2d12c98 to your computer and use it in GitHub Desktop.
Save mhartington/e61d68aca91215528a95a61cd2d12c98 to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
public items;
constructor(
public http: Http
) {
this.http.get('/api/feed')
.map(res => res.json())
.subscribe(res => this.items = res);
}
}
var express = require('express');
var app = express();
app.get('/api/feed', function(req, res) {
res.json({
name: 'feed',
items: ['first', 'second']
});
});
var server = app.listen(3000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
{
"name": "tmp",
"app_id": "",
"v2": true,
"typescript": true,
"proxies": [{
"path": "/api",
"proxyUrl": "http://0.0.0.0:3000/api"
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment