Last active
May 14, 2020 00:49
-
-
Save rodolfofranco/d53f5b0c206df5c1a286cf1960dab9ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is what our endpoint does when it receives a POST request from our app to create a client | |
//axios is the library we use to make HTTP calls | |
//We are running this on a Firebase Cloud Function | |
var response = await axios.post('https://api.mindbodyonline.com/public/v6/usertoken/issue', { | |
"Username": "Siteowner", | |
"Password": "apitest1234" | |
}, { | |
headers: { | |
'Content-Type': 'application/json', | |
'Api-Key': mindBodyApiKey, | |
'SiteId': '-99' | |
} | |
}) | |
console.log(response.data); | |
var accessToken = response.data.AccessToken; | |
try { | |
var addClientResponse = await axios({ | |
method: 'POST', | |
url: 'https://api.mindbodyonline.com/public/v6/client/addclient', | |
body: req.body, | |
headers: { | |
'Content-Type': 'application/json', | |
'SiteId': '-99', | |
'Api-Key': mindBodyApiKey, | |
'Authorization': 'Bearer ' + accessToken, | |
} | |
}) | |
console.log(addClientResponse.data); | |
res.send('post client') | |
} catch (err) { | |
console.log('da error', err.response.data); | |
res.send(err.response.data); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment