forked from nativescript-community/https
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain-page.ts
More file actions
99 lines (65 loc) · 1.93 KB
/
main-page.ts
File metadata and controls
99 lines (65 loc) · 1.93 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
import * as application from 'application'
import { Observable, EventData } from 'data/observable'
import { Page, NavigatedData } from 'ui/page'
import { View } from 'ui/core/view'
import { File, Folder, knownFolders, path } from 'file-system'
import * as Https from 'nativescript-https'
export function onLoaded(args: EventData) {
let page: Page = <Page>args.object
page.bindingContext = new MainPage()
}
export function onUnloaded(args: EventData) {
let page: Page = <Page>args.object
}
class MainPage extends Observable {
constructor() {
super()
}
}
export function testit(args: EventData) {
let view = args.object as View
let page = view.page as Page
let context = page.bindingContext as MainPage
Https.request({
url: 'https://wegossipapp.com/api/newuser',
method: 'GET',
// method: 'POST',
headers: {
'x-version': '4.2.0',
'x-env': 'DEVELOPMENT',
},
// content: JSON.stringify({ dis: 'is awesome' })
}).then(function(response) {
console.log('Https.request response', response)
console.dump(response)
}).catch(function(error) {
console.error('Https.request error', error)
})
}
export function enableSSL(args: EventData) {
let dir = knownFolders.currentApp().getFolder('certs')
let certificate = dir.getFile('wegossipapp.com.cer').path
Https.enableSSLPinning({ host: 'wegossipapp.com', certificate })
}
export function disableSSL(args: EventData) {
Https.disableSSLPinning()
}
// Https.request({
// url: 'https://wegossipapp.com/api/newuser',
// method: 'POST',
// headers: {
// 'Authorization': 'Basic ZWx1c3VhcmlvOnlsYWNsYXZl',
// 'x-uuid': 'aHR0cHdhdGNoOmY',
// 'x-version': '4.2.0',
// 'x-env': 'DEVELOPMENT',
// },
// content: JSON.stringify({
// 'username': 'roblav96',
// 'password': 'password',
// })
// }).then(function(response) {
// console.log('Https.request response', response)
// }).catch(function(error) {
// console.error('Https.request error', error)
// })