Skip to content

Commit c42195a

Browse files
committed
🚧 Add login with api
1 parent bd26fc5 commit c42195a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/client.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
import * as sapper from '@sapper/app'
1+
import { start, goto, prefetch, prefetchRoutes } from '@sapper/app'
2+
import UserService from './services/user.service'
23

3-
sapper.start({
4+
start({
45
target: document.querySelector('#sapper'),
6+
}).then(async function() {
7+
const { status } = await UserService.validate()
8+
9+
console.log(status)
10+
11+
// status !== 200 && goto('login')
512
})
13+
14+
prefetch('platform/profile').then(() => {
15+
console.log('PREFETCH')
16+
})
17+
18+
prefetchRoutes().then(() => console.log('PREFETCH ROUTES'))

src/containers/FormLogin.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
}
1313
1414
async function login() {
15+
const res = await UserService.login(user)
16+
1517
const {
1618
status,
1719
data: { field, error },
18-
} = await UserService.login(user)
20+
} = res
1921
2022
if (status === 200) {
2123
goto('platform/courses')

0 commit comments

Comments
 (0)