File tree 4 files changed +402
-0
lines changed 4 files changed +402
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ <h2>HTTP request from inside WASM in Dart - list of demos</h2>
12
12
< li > < a href ="package-fetch-api/ "> Demo using package:fetch_api</ a > </ li >
13
13
< li > < a href ="package-fetch-client/ "> Demo using package:fetch_client</ a > </ li >
14
14
< li > < a href ="package-http/ "> Demo using package:http</ a > </ li >
15
+ < li > < a href ="package-requests/ "> Demo using package:requests</ a > </ li >
15
16
< li > < a href ="package-web/ "> Demo using package:web and fetch()</ a > </ li >
16
17
</ ol >
17
18
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < title > HTTP request from WASM in Dart using package:requests</ title >
7
+ < script type ="module ">
8
+ import { instantiate , invoke } from "./main.mjs" ;
9
+
10
+ const module = await WebAssembly . compileStreaming ( fetch ( 'main.wasm' ) ) ;
11
+ const instance = await instantiate ( module ) ;
12
+ invoke ( instance ) ;
13
+ </ script >
14
+ </ head >
15
+
16
+ < body >
17
+ < h2 > HTTP Request from inside WASM in Dart using package:requests</ h2 >
18
+
19
+ < p > This example uses < a href ="https://pub.dev/packages/requests "> packages/requests</ a > , but its new version 5.0.0 from
20
+ < a href ="https://github.com/jossef/requests/releases/tag/5.0.0 "> Github repo</ a > .</ p >
21
+
22
+ < p > See the output in browser developer console.</ p >
23
+
24
+ < p > Actual code:</ p >
25
+ < pre >
26
+
27
+ import 'package:requests/requests.dart';
28
+
29
+ void main() async {
30
+ final resp = await Requests.get('https://httpbin.org/anything');
31
+ print('body: ${resp.content()}');
32
+ }
33
+
34
+ </ pre >
35
+ < section >
36
+ < h4 > Info</ h4 >
37
+ < ul >
38
+ < li > < a href ="https://github.com/wasm-outbound-http-examples/dart/blob/main/browser-package-requests "> Demo
39
+ source code</ a > </ li >
40
+ < li > Versions used on the moment of build:< small >
41
+ Dart SDK: < a href ="https://github.com/dart-lang/sdk/releases/tag/3.5.2 "> v3.5.2</ a > ,
42
+ package:requests: < a href ="https://github.com/jossef/requests/releases/tag/5.0.0 "> v5.0.0</ a > .
43
+ </ small > </ li >
44
+ </ ul >
45
+ </ section >
46
+ < footer > < small > Created for (wannabe-awesome) < a href ="https://github.com/vasilev/HTTP-request-from-inside-WASM "> list</ a > </ small > </ footer >
47
+ </ body >
48
+ </ html >
You can’t perform that action at this time.
0 commit comments