Open angelitoTalens opened 6 years ago
@angelitoTalens did you get to the bottom of this?
This is working fine for me in v7, how did you setup your in memory data service?
@hungerregnuh
mock-api.service.ts
export class MockApiService implements InMemoryDbService {
createDb() {
let login:{email:string, password:string}[] = [{
email:'first.last@gmail.com',
password:'pwd'
}];
return {
login
};
}
}
In app.module.ts
imports: [
...
environment.production ?
[] : HttpClientInMemoryWebApiModule.forRoot(MockApiService, {post204: false, post409: true, dataEncapsulation: false})
],
@angelitoTalens
could you try this instead?
createDb() {
const login = [
{
id: 1,
email: 'first.last@gmail.com',
password: 'pwd'
}
];
@hungerregnuh
your suggestion worked for me.
let userCredentials = {email: email, password: password};
return this.http.post<boolean>(apiUrl, userCredentials, options)
Encountered this error: body:error:"Collection 'inputparams' id type is non-numeric or unknown. Can only generate numeric ids." status:422 statusText:"Unprocessable Entity"
when doing a post using:
Angular 7
angular-in-memory-web-api
const url = ${this.apiUrl}
;
return this.http.post(url, JSON.stringify( param), httpOptions).pipe(map(this.serviceHelper.extractData))
.pipe(catchError(this.serviceHelper.handleError));](url)
here is what the "param" consists of common: OEGenericInputParameter; fleet: OEInputParameterWideBody[]; optional: OEInputParameterOptions;
User gives details in the form all the details are clubbed and made as param model createDB(){ const inputparamsfun = () =>{ what to be given here? } }
Encountered this error: body:error:"Collection 'login' id type is non-numeric or unknown. Can only generate numeric ids." status:422 statusText:"Unprocessable Entity"
when doing a post using:
const options = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
const body = JSON.stringify({email: email, password: password});
return this.http.post<boolean>(apiUrl, body, options);