I am using firebase realtime database in plain js
my code:
Set(ref(database, 'users/' + user.uid),{
username: username,
})
my error:
Constructor Set requires 'new'
i just tried my code that was written using a tutorial on yt
Related
Well I'd like to perform a GET Request of this URL: localhost:8080/home/data. Well if I'd like to access this URL i have to authenticate with a username and a password.
This is my code:
getDataAxios(){
axios.get('localhost:8080/home/data', {
auth: {
username: 'user.user#provider.com',
password: 'password'
}
})
.then(function (response) {
console.log(response);
})
}
And if I press a ceratin button on the React.js website the data which will come from that url should be displayed on the console. Somehow it is not working with this error:
Uncaught TypeError: Cannot read property 'get' of undefined
BTW. The backend is working. I verified it with Java.
That error seems to be coming from the axios library, instead of an error in your backend or something. The Uncaught TypeError means is that the axios library is not been imported properly, or the scope where you're invoking axios is not accessible. Check that you're importing the library on your React component. It should be something like:
import axios from 'axios';
In the top of your component.
I'm trying to learn about Cloud Functions for Firebase. I followed a tutorial to create an auth trigger and it worked great, but now I need to pass the username that the user wants to use to my auth event. How do I do this? Did I maybe use the wrong trigger here and instead needed an HTTP trigger?
exports.newUserSignup = functions.auth.user().onCreate(user => {
console.log('user created', user.email, user.uid);
const doc = admin.firestore().collection('users').doc();
return doc.set({
createDate: admin.firestore.FieldValue.serverTimestamp(),
modifiedDate: admin.firestore.FieldValue.serverTimestamp(),
username: 'NEED TO FIGURE THIS OUT',
email: user.email,
stat: 1,
uid: user.uid,
rowpointer: doc.id,
});
});
There is no way to pass additional information to the auth.user().onCreate trigger, and unfortunately there is no way to trigger when the account gets updated.
Your current options are:
Create the document from within your application code after the account has been created.
Pass all information to a Callable or HTTP Cloud Function, and let that handle both the account creation and the writing to Firestore.
Both are completely valid options, so pick the one that seems most reasonable to you.
Also see:
How to complete login only after functions.auth.user().onCreate is finished
Firebase Cloud Function - null user.displayName onCreate
firebase cloud function authentication: onCreate event doesn't contain displayName
Firebase functions user().onCreate: Pass parameters
Hi getstream community,
I am building a feed application with react native and node.js. I am struggling to add activities using the getstream.io js client, but I can do it with react-native-activity-feed's <StatusUpdateForm/> component. I get the following error with the js client:
An error occured when submitting activity: Error: {"detail":"You don't have the permission to do this","status_code":403,"code":17,"exception":"NotAllowedException","duration":"0.16ms"} with HTTP status code 403
I've set up the backend to send me a user token and initialize a user feed:
const streamClient = stream.connect(STREAM_KEY, STREAM_SECRET, STREAM_ID);
gsToken = streamClient.createUserToken(decodedToken.user_id);
streamClient.feed('user', decodedToken.user_id);
In the frontend I render a feed using <StreaApp/> & <FlatFeed/>
I've set up the post screen to send a sample activity on press to the feed:
var client = stream.connect(config.stream.app.key, config.stream.app.token, config.stream.app.id);
var user_feed = client.feed('user', config.stream.app.userId);
user_feed.addActivity({
actor: config.stream.app.userId,
tweet: 'Hello World I am finally here',
verb: 'Tweet',
object: 1
})
.then(function(data) { console.log('Activity Added! ' + data)})
.catch(function(err) { console.log('An error occured when submitting activity: ' + err)});
SideNote: I would like to use the js client instead of the react-native package so I can have more flexibility with UI.
When using user tokens please make sure to call setUser
let feed = client.feed("user", "jack");
await client.setUser({name: 'Jack'});
await userFeed.addActivity({
actor: client.currentUser,
verb: "post",
object: "my object",
})
this will populate client.currentUser which you can use as actor as well as store the user data in the actor field.
I want to Read my firebase data once for telegram bot, but I got this error:
D:\Projects 2016\Web\BOT\node-telegram-bot-api-sedric-bot\src\index.js:39
var userId = firebase.auth().currentUser.uid;
^
TypeError: Cannot read property 'uid' of null
And I used This From Google Tutorial, and this is my Function:
function readonce() {
var userId = firebase.auth().currentUser.uid;
return firebase.database().ref('/users/' + userId).once('value').then(function(snapshot) {
var username = snapshot.val().username;
// ...
});
}
readonce()
I Read all of Tutorials on the net, But I Couldn't understand to read data by java script
It seems that you're using the Firebase Admin SDK in your Node script. The Admin SDK runs as an administrative level super-user, which doesn't have a defined identity. As such there is no firebase.auth().currentUser.
This sounds like a XY problem: a node script is not running as a specific user. So whose user name are you trying to look up? And what is it that you're trying to do with the user name?
Im getting error on using Google API.
having right to connect with Google Drive and add new sheet and insert data into it.
It was working till yesterday but when i run the application today.
Im getting error :
Error appears after users given token and tried to access the DRIVE API to get all the files
domain: "usageLimits"
extendedHelp: "https://code.google.com/apis/console"
message: "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
reason: "dailyLimitExceededUnreg"
I have not changed any settings.
Following API are enables for my application access token. Do i have to add / enable more API to make it work.
I was using NodeJS to download a file, but was forgetting to pass the auth.
Initially I was using:
function downloadFiles() {
const service = google.drive('v3');
const dest = fs.createWriteStream('/tmp/foo.csv');
const fileId = '12345_ID_GOES_HERE';
service.files.export({
fileId: fileId,
mimeType: 'text/csv'
});
}
afterwards, I added an auth argument to the function, and passed it to the export method as well:
function downloadFiles(auth) {
const service = google.drive('v3');
const dest = fs.createWriteStream('/tmp/foo.csv');
const fileId = '12345_ID_GOES_HERE';
service.files.export({
auth: auth,
fileId: fileId,
mimeType: 'text/csv'
})
}
I am getting auth by creating an instance of google-auth-library
The problem was while getting access token. I was not providing correct scopes.
When i changed the scope to
https://spreadsheets.google.com/feeds https://docs.google.com/feeds
https://www.googleapis.com/auth/drive.file
it worked fine