Skip to content

Commit d43f227

Browse files
Added debug statements
1 parent 9d6f800 commit d43f227

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

demo/app/main-page.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//
22

3-
import {EventData, Observable} from 'tns-core-modules/data/observable'
4-
import {Page} from 'tns-core-modules/ui/page'
5-
import {View} from 'tns-core-modules/ui/core/view'
6-
import {knownFolders} from 'tns-core-modules/file-system'
7-
import * as Https from 'nativescript-https'
3+
import {EventData, Observable} from 'tns-core-modules/data/observable';
4+
import {Page} from 'tns-core-modules/ui/page';
5+
import {View} from 'tns-core-modules/ui/core/view';
6+
import {knownFolders} from 'tns-core-modules/file-system';
7+
import * as Https from 'nativescript-https';
88

99

1010
export function onLoaded(args: EventData) {
@@ -18,6 +18,8 @@ export function onUnloaded(args: EventData) {
1818

1919
class MainPage extends Observable {
2020

21+
textView: string;
22+
2123
constructor() {
2224
super()
2325
}
@@ -43,8 +45,10 @@ export function testit(args: EventData) {
4345
// content: JSON.stringify({ dis: 'is awesome' })
4446
}).then(function (response) {
4547
console.log('Https.request response', response);
48+
context.textView = JSON.stringify(response, null, 2);
4649
}).catch(function (error) {
47-
console.error('Https.request error', error)
50+
console.error('Https.request error', error);
51+
context.textView = JSON.stringify(error, null, 2);
4852
})
4953

5054
}

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Button text="Test HTTPS" tap="testit" />
1212
<Button text="Enable SSL" tap="enableSSL" />
1313
<Button text="Disable SSL" tap="disableSSL" />
14-
<TextView text=""></TextView>
14+
<TextView text="{{ responseText }}"/>
1515
</StackLayout>
1616
</GridLayout>
1717

https.android.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function getClient(reload: boolean = false): okhttp3.OkHttpClient {
144144
console.warn('nativescript-https > Undefined host or certificate. SSL pinning NOT working!!!')
145145
}
146146
}
147-
Client = client.build()
147+
Client = client.build();
148148
return Client
149149
}
150150

@@ -157,8 +157,10 @@ export function request(opts: Https.HttpsRequestOptions): Promise<Https.HttpsRes
157157
return new Promise(function (resolve, reject) {
158158
try {
159159
let client = getClient();
160-
161-
const urlBuilder = okhttp3.HttpUrl.parse(opts.url).newBuilder();
160+
console.log("Attempting to construct URL");
161+
const httpUrl: okhttp3.HttpUrl = okhttp3.HttpUrl.parse(opts.url);
162+
const urlBuilder = httpUrl.newBuilder();
163+
console.log("Created newBuilder");
162164
if (opts.params) {
163165
Object.keys(opts.params).forEach(param => {
164166
urlBuilder.addQueryParameter(param, opts.params[param] as any);

0 commit comments

Comments
 (0)