Created
December 11, 2019 03:28
-
-
Save duhaime/1f515fc37d843c0bc852fd758e3b5836 to your computer and use it in GitHub Desktop.
Firebase Cloud Function
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
const functions = require('firebase-functions'); | |
const axios = require('axios'); | |
exports.helloWorld = functions.https.onRequest((request, response) => { | |
response.set('Access-Control-Allow-Origin', '*'); | |
response.set('Access-Control-Allow-Methods', 'GET, POST'); | |
const url = 'https://travel-birds-app.firebaseio.com/users/9b74fd7a-1a2b-11ea-9b18-f45c89b66fa9.json'; | |
return axios.get(url) | |
.then(data => response.status(200).json({ | |
message: data.data, | |
})) | |
.catch(err => response.status(500).json({ | |
error: err, | |
})) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment