Skip to content

Commit

Permalink
tried to encode body params
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan Leopold committed Jan 19, 2021
1 parent f0fb485 commit 5a1f563
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/FlightForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ class FlightForm extends Component {
client_secret: `${process.env.REACT_APP_AMADEUS_SECRET}`
});

let tokenForm = new URLSearchParams()
let encoded = encodeURIComponent(postData)

console.log(postData)
console.log(encoded)

let tokenForm = new URLSearchParams()
tokenForm.append('grant_type', 'client_credentials')
tokenForm.append('client_id', process.env.REACT_APP_AMADEUS_KEY)
tokenForm.append('client_secret', process.env.REACT_APP_AMADEUS_SECRET)
Expand All @@ -81,8 +85,11 @@ class FlightForm extends Component {
headers: {
"Content-Type":"application/x-www-form-urlencoded",
},
data: tokenForm
data: `${encoded}`
})
// axios.post('https://test.api.amadeus.com/v1/security/oauth2/token/', JSON.stringify(tokenForm), {
// headers: {"Content-Type":"application/x-www-form-urlencoded"}
// })
.then( function(response) {
console.log(response.data)
}).catch( err => console.log(err))
Expand Down

0 comments on commit 5a1f563

Please sign in to comment.