Skip to content

Instantly share code, notes, and snippets.

@duhaime
Created December 11, 2019 03:28
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 duhaime/1f515fc37d843c0bc852fd758e3b5836 to your computer and use it in GitHub Desktop.
Save duhaime/1f515fc37d843c0bc852fd758e3b5836 to your computer and use it in GitHub Desktop.
Firebase Cloud Function
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