diff --git a/aurelia-app/src/components/profile.html b/aurelia-app/src/components/profile.html
index 28b9a6d..cafbfad 100644
--- a/aurelia-app/src/components/profile.html
+++ b/aurelia-app/src/components/profile.html
@@ -23,7 +23,7 @@
${owner.name} ${owner.surname} | ${name}
${j.name}
CHECK WHO I'M FOLLOWING
-
diff --git a/aurelia-app/src/components/profile.js b/aurelia-app/src/components/profile.js
index dae83ec..81a37f3 100644
--- a/aurelia-app/src/components/profile.js
+++ b/aurelia-app/src/components/profile.js
@@ -1,31 +1,37 @@
import { RestApi } from 'services/api'
import {AuthService} from 'aurelia-authentication';
import {Login} from "./login/login";
+import {Config} from "aurelia-api";
+
export class Profile {
- static inject = [RestApi, AuthService, Login]
+ static inject = [RestApi, AuthService, Login, Config]
- constructor(restApi, authService, login) {
+ constructor(restApi, authService, login, config) {
this.restApi = restApi
this.authService = authService
this.login = login
+ this.apiEndpoint = config.getEndpoint('api')
}
activate(params, routeConfig) {
this.restApi.getJourneysOfUser(params.id).then(journeys => this.journeys = journeys)
return this.restApi.getUser(params.id).then(user => {
- Object.assign(this, ...user);
+ this.user = user;
})
}
follow() {
if (!this.authService.authenticated) {
- console.log('you are not auth')
this.login.authenticate('facebook')
- } else {
- console.log('you are auth')
+ if (!this.authService.authenticated) {
+ return
+ }
}
+ return this.authService.getMe().then(
+ profile => this.apiEndpoint.post(`/users/${profile.id}/followers`, { "id": this.user.id })
+ )
}
}