Skip to content

Instantly share code, notes, and snippets.

@ksakae1216
ksakae1216 / html
Last active August 20, 2021 02:09
<a href="https://www.ksakae1216.com/archive" target="_blank" rel=“noopener noreferrer”>
export class AppComponent implements OnInit {
soccerData = '';
baseballData = '';
constructor(private http: HttpClient){}
ngOnInit():void {
this.getData('soccer');
this.getData('baseball');
}
const jsonServer = require('json-server')
const server = jsonServer.create()
const path = require('path')
const router = jsonServer.router(path.join(__dirname, 'db.json')) // 今回のようにmockディレクトリ作成して別のフォルダでmock起動するときは必要
const middlewares = jsonServer.defaults()
server.use(jsonServer.rewriter({
"/api/*": "/$1" // /api/soccer -> /soccer
}))
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"proxyConfig": "mock/proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "json-server-sample:build:production"
},
"development": {
{
"/api": {
"target": "http://localhost:3000",
"secure": false
}
}
"scripts": {
"ng": "ng",
"start": "ng serve",
"mock": "node ./mock/server.js",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
{
"soccer": [
{ "id": 7, "name": "kubo", "position": "MF", "createdAt": "2021/08/09 10:00:00" },
{ "id": 10, "name": "doan", "position": "MF", "createdAt": "2021/08/09 10:00:00"},
{ "id": 4, "name": "yoshida", "position": "CB", "createdAt": "2021/08/09 10:00:00"}
],
"baseball": [
{ "id": 6, "name": "sakamoto", "position": "ショート", "createdAt": "2021/08/09 10:00:00" },
{ "id": 51, "name": "suzuki", "position": "センター", "createdAt": "2021/08/09 10:00:00" }
]
yarn add --dev json-server
ng @briebug/jest-schematic:add
npm install @briebug/jest-schematic