11import * as Https from "nativescript-https" ;
2- import * as Observable from "tns-core-modules/data/observable" ;
3- import * as fs from "tns-core-modules/file-system" ;
4- import * as dialogs from "tns-core-modules/ui/dialogs" ;
5- import * as Page from "tns-core-modules/ui/page" ;
6-
2+ import { fromObject , Dialogs as dialogs , Page , EventData } from "@nativescript/core" ;
3+ import * as fs from "@nativescript/core/file-system" ;
74let page ;
85let viewModel ;
9- export function pageLoaded ( args : Page . NavigatedData ) {
10- page = args . object as Page . Page ;
11- viewModel = Observable . fromObject ( {
6+ export function pageLoaded ( args : EventData ) {
7+ page = args . object as Page ;
8+ viewModel = fromObject ( {
129 enabled : false ,
1310 progress : 0 ,
1411 currentRequest : null ,
@@ -138,10 +135,24 @@ export function getMockbin() {
138135}
139136
140137export function get404 ( ) {
141- getRequest ( "https://mockbin.com/reque2st" ) ;
138+ Https . request ( {
139+ url : "https://httpbin.org/json" ,
140+ method : "GET" ,
141+ headers : {
142+ "Content-Type" : "application/json; charset=utf-8"
143+ } ,
144+ body : { foo :"bar" } ,
145+ allowLargeResponse : true
146+ } ) . then ( res => {
147+ console . log ( res . content )
148+ console . log ( res . content . slideshow )
149+ } ) . catch ( err => {
150+ console . log ( "error >>>" , err ) ;
151+ } )
152+ //getRequest("https://mockbin.com/reque2st");
142153}
143154
144- export function enableSSLPinning ( args : Observable . EventData ) {
155+ export function enableSSLPinning ( args : EventData ) {
145156 let dir = fs . knownFolders . currentApp ( ) . getFolder ( "assets" ) ;
146157 let certificate = dir . getFile ( "httpbin.org.cer" ) . path ;
147158 Https . enableSSLPinning ( {
@@ -152,14 +163,14 @@ export function enableSSLPinning(args: Observable.EventData) {
152163 console . log ( "enabled" ) ;
153164}
154165
155- export function enableSSLPinningExpired ( args : Observable . EventData ) {
166+ export function enableSSLPinningExpired ( args : EventData ) {
156167 let dir = fs . knownFolders . currentApp ( ) . getFolder ( "assets" ) ;
157168 let certificate = dir . getFile ( "httpbin.org.expired.cer" ) . path ;
158169 Https . enableSSLPinning ( { host : "httpbin.org" , certificate } ) ;
159170 console . log ( "enabled" ) ;
160171}
161172
162- export function disableSSLPinning ( args : Observable . EventData ) {
173+ export function disableSSLPinning ( args : EventData ) {
163174 Https . disableSSLPinning ( ) ;
164175 console . log ( "disabled" ) ;
165176}
0 commit comments