🔧 properly use static/public
This commit is contained in:
parent
167022f587
commit
3719dcbaeb
@ -1,17 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import api from '$lib/api';
|
import api from '$lib/api';
|
||||||
import { tokenStore, userStore } from '../stores';
|
import { tokenStore, userStore } from '../stores';
|
||||||
|
import { PUBLIC_INSTANCE_URL } from '$env/static/public';
|
||||||
const INSTANCE_URL = 'http://localhost:4000';
|
|
||||||
|
|
||||||
let username = '';
|
let username = '';
|
||||||
let password = '';
|
let password = '';
|
||||||
|
|
||||||
const onLogin = async () => {
|
const onLogin = async () => {
|
||||||
const app = await api.oauth.createApp(INSTANCE_URL);
|
const app = await api.oauth.createApp(PUBLIC_INSTANCE_URL);
|
||||||
const result = await api.oauth.getTokenFromCredentials(INSTANCE_URL, app, username, password);
|
const result = await api.oauth.getTokenFromCredentials(
|
||||||
|
PUBLIC_INSTANCE_URL,
|
||||||
|
app,
|
||||||
|
username,
|
||||||
|
password
|
||||||
|
);
|
||||||
tokenStore.set(result.access_token);
|
tokenStore.set(result.access_token);
|
||||||
const user = await api.user.verifyCredentials(INSTANCE_URL, result.access_token);
|
const user = await api.user.verifyCredentials(PUBLIC_INSTANCE_URL, result.access_token);
|
||||||
console.log('user', user);
|
console.log('user', user);
|
||||||
userStore.set(user);
|
userStore.set(user);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user