summaryrefslogtreecommitdiff
path: root/mobile/app/main-view-model.ts
blob: 714abe1ff8f6785e385ea3f84d06375786ab939f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Frame, Http, Observable } from '@nativescript/core';

export class LoginModel extends Observable {
  public server: string = 'http://192.168.178.59:8080';
  public username: string;
  public password: string;

  constructor() {
    super();
  }

  async onLogin() {
    const content = new FormData();
    content.append('username', this.username);
    content.append('password', this.password);
    const response = await Http.request({
      url: this.server,
      method: 'POST',
      content: content,
    });

    console.log(response.content?.toString());
  }

  goToGalleries() {
    const frame = Frame.topmost();
    frame.navigate('gallery-page');
  }
}