10 seconds to build virtual interfaces in angular.
My sister was still in primary school, but it took her only 1 minutes to learn how to use it. It's too simple.
install:
- npm i --save ng-mocker
- // in app.module.ts
- import { MockerModule } from 'ng-mocker'
- // ...
- imports: [
- HttpClientModule,
- MockerModule.forRoot(Mocks),
- ],
- export class Mocks {
- host: string = 'http://github.com'
- '/users/options'(req): any {
- return { message: 'ok!' }
- }
- }
when you request /users/options with angular, {message:'ok!'} will be returned.
来源: https://juejin.im/entry/5a3535fff265da433227a4f7