Skip to content

Commit

Permalink
working on a testcall.js to access the new amadeus flight apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan Leopold committed Jun 3, 2021
1 parent a1910bd commit 65d5d96
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
6 changes: 2 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {Route, Link} from "react-router-dom"
import "./App.css";
import FlightForm from "./FlightForm";
import TestCall from './TestCall'
// import Login from "./Login"
// import CreateUser from "./CreateUser";
import axios from "axios";


Expand Down Expand Up @@ -57,8 +55,8 @@ class App extends Component {
</div>
</header>
<div>
<Route path="/tester" exact render={ (routerProps) => <TestCall {...routerProps} {...this.props} {...this.state} />} ></Route>
<Route path="/" exact render={ (routerProps) => <FlightForm {...routerProps}{...this.props}{...this.state}/> } ></Route>
<Route path="/tester" exact render={ (routerProps) => <TestCall {...routerProps} {...this.props} {...this.state}/> } > </Route>
<Route path="/" exact render={ (routerProps) => <FlightForm {...routerProps}{...this.props}{...this.state}/> } > </Route>
</div>
</div>
);
Expand Down
42 changes: 30 additions & 12 deletions src/TestCall.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import axios from "axios"

const TestCall = async () => {
const TestCall = (props) => {

// let testFlights = await axios({
// method: "get",
// url: `https://test.api.amadeus.com/v1/reference-data/locations?subType=AIRPORT&keyword=${event.target.value}`,
// headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// Authorization: `Bearer ${this.props.oAuth}`,
// },
// })
const [flights, refreshFlights] = useState()

let grabFlights = async () => {

try {

console.log(props.oAuth, "OAUTH")
let testFlights = await axios({
method: "GET",
url: `https://test.api.amadeus.com/v2/shopping/flight-offers/?originLocationCode="SFO"&destinationLocationCode="JFK"&departureDate="2021-08-15"&returnDate="2021-08-22"`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: `Bearer ${props.oAuth}`,
},
})

refreshFlights(testFlights)

} catch (err) {

console.log(err)

}

}

grabFlights().then( result => console.log(result) )

return (
<div>

</div>
)

}


Expand Down

0 comments on commit 65d5d96

Please sign in to comment.