I have been assigned on a task to fetch all tweets from a certain hashtag and send that data to my application. So I decided to use firebase cloud functions, I generated the key needed for the twitter api. I also tested get my homepage using postman status and worked, however my issue now when I test my code on good cloud functions I cant get it to work and the error message when I try this end point:
Error: could not handle the request
or
https://us-central1-don.cloudfunctions.net/api/statuses/user_timeline
and this is my code on firebase cloud functions
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const express = require('express');
const Twitter = require('twitter');
admin.initializeApp(functions.config().firebase);
const client = new Twitter({
consumer_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
consumer_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});
const app = express();
/* Express */
app.get('/', function(req,res){
client.get('statuses/user_timeline', {screen_name: 'nodejs', count: 5}, function (error, tweets, response) {
if (!error) {
response.send({ title: 'Express', tweets: tweets })
}
else {
response.send({ error: "this is error: " + error })
}
});
});
// Cloud Function
exports.api = functions.https.onRequest(app)
Hope anyone can suggest any solutions, thanks.
Update: here is my function console where it also throws an error:
api Function execution took 8 ms, finished with status code: 404
api Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions