11import React , { Component } from 'react' ;
2- import logo from './logo.svg' ;
2+
33import './App.css' ;
44
55class App extends Component {
66
7- async postData ( ) {
7+ async postTicketData ( ) {
8+
9+ let auth = btoa ( 'niilo:salasana' ) ;
10+ let result = await fetch ( "https://ticketguru.herokuapp.com/api/events/1/tickets" , {
11+ method : 'post' ,
12+ mode : 'cors' ,
13+ cache : 'no-cache' ,
14+ credentials : 'same-origin' ,
15+ headers : {
16+ 'Accept' : 'application/json' ,
17+ 'Content-Type' : 'application/json' ,
18+ 'Authorization' : 'Basic ' + auth ,
19+ } ,
20+ body : JSON . stringify ( {
21+
22+ pcs : '3' ,
23+ orderid : '14' ,
24+ tickettypeid : '4' ,
25+
26+ } )
27+
28+
29+ } ) ;
30+
31+ console . log ( result ) ;
32+ }
33+
34+
35+ async postOrderData ( ) {
836
937 let auth = btoa ( 'niilo:salasana' ) ;
10- let result = await fetch ( "https://ticketguru.herokuapp.com/api/tickets /" , {
38+ let result = await fetch ( "https://ticketguru.herokuapp.com/api/orders /" , {
1139 method : 'post' ,
1240 mode : 'cors' ,
1341 cache : 'no-cache' ,
@@ -18,9 +46,8 @@ class App extends Component {
1846 'Authorization' : 'Basic ' + auth ,
1947 } ,
2048 body : JSON . stringify ( {
21- eventid : '1' ,
22- tickettypeid : '6' ,
23- isvalid : 'true' ,
49+ orderid : '1' ,
50+
2451
2552 } )
2653
@@ -36,7 +63,9 @@ class App extends Component {
3663
3764 < div className = "App" >
3865
39- < button onClick = { ( ) => this . postData ( ) } > Post ticket order data</ button >
66+ < button onClick = { ( ) => this . postOrderData ( ) } > Post order data</ button >
67+
68+ < button onClick = { ( ) => this . postTicketData ( ) } > Post ticket data</ button >
4069
4170 </ div >
4271
@@ -47,4 +76,34 @@ class App extends Component {
4776
4877}
4978
50- export default App ;
79+ export default App ;
80+
81+
82+
83+
84+ /* async postData(){
85+
86+
87+ let auth = btoa('niilo:salasana');
88+ let result = await fetch("https://ticketguru.herokuapp.com/api/tickets/", {
89+ method : 'post',
90+ mode: 'cors',
91+ cache : 'no-cache',
92+ credentials : 'same-origin',
93+ headers : {
94+ 'Accept': 'application/json',
95+ 'Content-Type' : 'application/json',
96+ 'Authorization' : 'Basic ' + auth,
97+ },
98+ body : JSON.stringify({
99+ eventid: '1',
100+ tickettypeid: '6',
101+ isvalid: 'true',
102+
103+ })
104+
105+
106+ });
107+
108+ console.log(result);
109+ } */
0 commit comments