Skip to content

Commit ec82cef

Browse files
committed
fix: call async methods to prevent android.os.NetworkOnMainThreadException errors
1 parent 8d03ad0 commit ec82cef

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/https/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ImageSource } from '@nativescript/core';
2-
import { request } from './request';
32
import type { HttpsRequestOptions } from './request';
3+
// eslint-disable-next-line no-duplicate-imports
4+
import { request } from './request';
45
export * from './request';
56

67
/**
@@ -9,7 +10,7 @@ export * from './request';
910
*/
1011
export async function getString(arg: string | HttpsRequestOptions): Promise<string> {
1112
const r = await request(typeof arg === 'string' ? { url: arg, method: 'GET' } : arg);
12-
return r.content.toString();
13+
return r.content.toStringAsync();
1314
}
1415

1516
/**
@@ -18,7 +19,7 @@ export async function getString(arg: string | HttpsRequestOptions): Promise<stri
1819
*/
1920
export async function getJSON<T>(arg: string | HttpsRequestOptions): Promise<T> {
2021
const r = await request(typeof arg === 'string' ? { url: arg, method: 'GET' } : arg);
21-
return r.content.toJSON();
22+
return r.content.toJSONAsync();
2223
}
2324

2425
/**

0 commit comments

Comments
 (0)