Reputation: 1823
tns 2.3.0
I've defined a User interface :
export interface User {
name: string,
pictureUrl: string,
coverUrl: string
}
chat.service :
@Injectable()
export class ChatService {
constructor(private http: Http) {}
getChat() {
let headers = new Headers();
headers.append("Authorization", "Bearer " + Config.token);
return this.http.get(Config.apiUrl + "/chat", {
headers: headers
})
.map(res => res.json())
.map(res => {
console.log("Chat:")
console.log(res)
console.log(res.participants.me.name)
let chat_data = res;
let me : User = {
name: chat_data.participants.me.name,
pictureUrl: chat_data.participants.me.pictureUrl,
coverUrl: chat_data.participants.me.coverUrl
};
let other : User = {
name: chat_data.participants.other.name,
pictureUrl: chat_data.participants.other.pictureUrl,
coverUrl: chat_data.participants.other.coverUrl
};
let messages : Message[] = chat_data.messages;
let chat : Chat = {
participants : {
me : me,
other: other
},
messages : messages
}
return chat;
})
.catch(this.handleErrors);
handleErrors(error: Response) { //line 58
console.log(JSON.stringify(error.json()));
return Observable.throw(error);
}
}
}
When building, I get the following error trace :
app/shared/chat/chat.service.ts(58,23): error TS1005: ',' expected.
app/shared/chat/chat.service.ts(58,35): error TS1005: ';' expected.
Upvotes: 0
Views: 349
Reputation: 881113
In your instantiation, you have a comma at the end of the second line and a semi-colon at the end of the third and fourth lines:
let me = new User {
name: me.name, <-- comma
pictureUrl: other.pictureUrl; <-- semicolon
coverUrl: other.coverUrl; <-- semicolon
};
Even knowing as little about Nativescript as I do, I'm guessing this is not right (based on the error messages and my knowledge of general syntax rules).
If that's true, by the way, you're probably better off deleting the question since it will almost certainly be closed as a simple typo.
Upvotes: 1