angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 232 forks source link

Multiple services issue #212

Open Coquie opened 6 years ago

Coquie commented 6 years ago

Hi, I'm having troubles using multiple services. I've seen the previous answers but it isn't working for me. This is my in-memory-data-service.ts file: `import { InMemoryDbService } from 'angular-in-memory-web-api';

export class InMemoryDataService implements InMemoryDbService { createDb() { const heroes = [ { id: 1, tipo: 'Extraordinaria', name: '18/07/2013' }, { id: 2, tipo: 'Ordinaria', name: '18/07/2013' }, { id: 3, tipo: 'Ordinaria', name: '18/07/2013' } ]; const archivos = [ { id: 1, titulo: 'Apertura', url: 'D:\Sesiones\2013\1.mp3', orden: 1, sesid: 1 }, { id: 2, titulo: 'Dip 1', url: 'D:\Sesiones\2013\dip1.mp3', orden: 2, sesid: 1 }, { id: 3, titulo: 'Dip 2', url: 'D:\Sesiones\2013\dip2.mp3', orden: 3, sesid: 1 }, { id: 4, titulo: 'Votacion', url: 'D:\Sesiones\2013\1.mp3', orden: 4, sesid: 1 } ]; return { heroes, archivos }; } }`

When I run it I get the following error:

./src/app/in-memory-data.service.ts Module parse failed: Octal literal in strict mode (18:58) You may need an appropriate loader to handle this file type. | ]; | var archivos = [ | { id: 1, titulo: 'Apertura', url: 'D:\Sesiones\2013\1.mp3', orden: 1, sesid: 1 }, | { id: 2, titulo: 'Dip 1', url: 'D:\Sesiones\2013\dip1.mp3', orden: 2, sesid: 1 }, | { id: 3, titulo: 'Dip 2', url: 'D:\Sesiones\2013\dip2.mp3', orden: 3, sesid: 1 },

brnelsons commented 5 years ago

bump. I'm having a similar issue. I have a set of services I'm trying to mock with this. /api/secured/configs /api/secured/something/a /api/secured/somethingelse/a /api/secured/somethingelse/b

and I need all 4 mocked.

Coquie commented 5 years ago

I went from the in memory api to an actual api so I don't remember all of it, but I'm pretty sure the problem was with the backlashes, you just need to escape them like "//"