Skip to content

Commit e9d2145

Browse files
committed
feat(backend): load user
1 parent 49fd688 commit e9d2145

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/plugin-backend/src/data.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ export const DataSet = (
2525
On.backend().PluginLoadUser(emitter, [
2626
async (id: string) => {
2727
// TODO: backend types
28-
await ofetch(`/api/user/${id}`, {
29-
method: 'POST',
28+
const { payload } = await ofetch(`/api/user/${id}`, {
29+
method: 'GET',
3030
async onRequestError() {
3131
hooks.toast.error(hooks.i18n.t('toast.user.fail'))
3232
},
3333
})
34+
35+
if (payload) {
36+
stores.AUTH.user = payload
37+
38+
hooks.toast.success(hooks.i18n.t('toast.user.success'))
39+
}
3440
},
3541
() => {},
3642
])

0 commit comments

Comments
 (0)