File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -29,3 +29,24 @@ const someObject = {
29
29
sendRequest ( "POST" , requestURL , someObject )
30
30
. then ( data => console . log ( data ) )
31
31
. catch ( error => console . error ( error ) )
32
+
33
+
34
+
35
+ async function sendRequestAsync ( model , url ) {
36
+ const response = await fetch ( url , {
37
+ method : 'POST' ,
38
+ headers : {
39
+ 'Content-Type' : 'application/json'
40
+ } ,
41
+ body : JSON . stringify ( model )
42
+ } ) ;
43
+ const data = await response . json ( ) ;
44
+ return data ;
45
+ }
46
+
47
+ async function fetchRequest ( ) {
48
+ const model = {
49
+ prop : "value" ,
50
+ }
51
+ const result = await sendRequestAsync ( model , url ) ;
52
+ }
Original file line number Diff line number Diff line change @@ -44,4 +44,4 @@ const someObject = {
44
44
45
45
sendRequest ( "POST" , requestURL , someObject )
46
46
. then ( data => console . log ( data ) )
47
- . catch ( error => console . error ( error ) )
47
+ . catch ( error => console . error ( error ) )
You can’t perform that action at this time.
0 commit comments