Skip to content

Instantly share code, notes, and snippets.

@rodolfofranco
Last active May 14, 2020 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodolfofranco/d53f5b0c206df5c1a286cf1960dab9ce to your computer and use it in GitHub Desktop.
Save rodolfofranco/d53f5b0c206df5c1a286cf1960dab9ce to your computer and use it in GitHub Desktop.
//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