Ik ben programmeur en studeer software engineering op Hogeschool Leiden.
import express from 'express';
const app = express();
const port = 3000;
const personalInfo = {
email: 'niels123.prins@gmail.com',
city: 'Nieuw-Vennep',
birthdate: '01-05-2000',
working_at: 'FreshPortal Software',
onion_site: 'nielsp3azmvkuwuwllknghcqxofvyhwfck3wsacs7pmlaoanekz2ncad.onion',
};
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
next();
});
app.get('/api/info', (req, res) =>
{
res.json(personalInfo);
});
app.listen(port, () => {
console.log(`API listening at http://localhost:${port}`);
});
import { Component, inject, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map, Observable } from "rxjs";
@Component({
template: `
<h1>Personal info</h1>
@for (data of personalInfo$ | async; track data[0]) {
{{ data[0] }}: {{ data[1] }}
}
`,
})
export class PersonalInfoComponent implements OnInit {
private apiUrl = 'http://localhost:3000/api/info';
public personalInfo$?: Observable<[string, string][]>;
private http = inject(HttpClient);
public ngOnInit() {
this.personalInfo$ = this.http.get(this.apiUrl).pipe(map((personalInfo) => {
return Object.entries(personalInfo);
}));
}
}