johnpapa / johnpapa/angular2-force

Cannot find name 'res' and other syntax errors

Open
#6 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
114
Forks
53
PR merge metrics
No merged PRs in 30d

Description

Angular 2 newbie here.

Thanks John Papa for awesome tutorial. I don't know if this is the right place to post this, but I am posting anyway.

I'm using webpack and following the ng-conf presentation. When I run `npm start` I get following error

```
ERROR in ./src/app/service/mock-data-service.service.ts
(13,25): error TS1005: '=>' expected.

ERROR in ./src/app/service/mock-data-service.service.ts
(13,27): error TS1005: ';' expected.

ERROR in ./src/app/service/mock-data-service.service.ts
(13,40): error TS1005: ';' expected.

ERROR in ./src/app/service/mock-data-service.service.ts
(13,30): error TS7027: Unreachable code detected.

ERROR in ./src/app/service/mock-data-service.service.ts
(13,30): error TS2304: Cannot find name 'res'.
Child html-webpack-plugin for "index.html":
chunk {0} index.html 512 kB
+ 3 hidden modules
webpack: bundle is now VALID.

```

and my contents in `mock-data-service.service.ts` are

```
import { Injectable } from '@angular/core';
import {Http, Response} from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class MockDataService {

constructor(private http: Http) {
}

getMockData() {
return this.http.get('./src/database/mockdata.json')
.map((res: Response)) => res.json());
}

}
```

You can view the full picture [here](https://github.com/ksharifbd/noksha/tree/http-json-service)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.