diff --git a/apps/toolbox/src/pages/http.ts b/apps/toolbox/src/pages/http.ts new file mode 100644 index 0000000000..87f1e629e5 --- /dev/null +++ b/apps/toolbox/src/pages/http.ts @@ -0,0 +1,29 @@ +import { Page, EventData, Application, File, Folder, knownFolders, path, getFileAccess, Utils, Http } from '@nativescript/core'; +import { AbortController } from '@nativescript/core/abortcontroller'; + +let page: Page; + +export function navigatingTo(args: EventData) { + page = args.object; +} + +export async function makeRequest(args) { + try { + // const result = await fetch('https://httpbin.org/get'); + const controller = new AbortController(); + console.log('getting json with okhttp!'); + // const result = await Http.getJSON('https://httpbin.org/get') + setTimeout(() => { + controller.abort(); + }, 0); + const result = await Http.request({ + method: 'GET', + url: 'https://httpbin.org/get', + signal: controller.signal as any, + }); + + console.log(result); + } catch (e) { + console.log(e.stack); + } +} diff --git a/apps/toolbox/src/pages/http.xml b/apps/toolbox/src/pages/http.xml new file mode 100644 index 0000000000..1017bb44eb --- /dev/null +++ b/apps/toolbox/src/pages/http.xml @@ -0,0 +1,6 @@ + + + +