所以我有这个问题,每当我添加一个新的用户帐户时,它就会启动已经登录的当前用户.我读了firebase api并且说" 如果新帐户已创建,则用户自动登录"但他们从未说过任何关于避免这种情况的事情.
//ADD EMPLOYEES
addEmployees: function(formData){
firebase.auth().createUserWithEmailAndPassword(formData.email, formData.password).then(function(data){
console.log(data);
});
},
Run Code Online (Sandbox Code Playgroud)
我是管理员,我正在为我的网站添加帐户.如果我可以添加帐户而不退出并登录新帐户,我希望如此.我能避免这种情况吗?
我在代码中遇到了一个小问题,这让我感到困惑,并希望有人可以解释为什么会这样做.
代码1
sendText(){
return this.http.get('/api')
.map((response:Response) => response.json());
}
Run Code Online (Sandbox Code Playgroud)
代码2
sendText(){
return this.http.get('/api').map((response:Response) => {
response.json();
});
}
Run Code Online (Sandbox Code Playgroud)
这两个代码之间的关键区别在于,在代码2中,我在箭头函数之后放置了括号,将我的任务添加到这些括号中,在代码1中,我将括号取出并将任务放在一行上.
我的问题是,为什么不从服务器端回来为未定义在未来我的目标代码2与angular2而提供的订阅方法代码1返回我怀疑的对象.
有人可以告诉我怎么做吗?
这是我到目前为止所拥有的,它没有将数据添加到我的数据库中
我在没有在常规 Web 应用程序上使用 lambda 函数的情况下对此进行了测试,并且可以正常工作
var http = require('http');
var firebase = require('firebase');
exports.handler = (event, context, callback) => {
var config = {
apiKey: "AIzaSyCpk23423Iy_akmUniqUJhLt234324YPBE1vD7At8Laj4",
authDomain: "echoproject-blah.firebaseapp.com",
databaseURL: "https://echoproject-blah.firebaseio.com",
storageBucket: "echoproject-blah.appspot.com",
messagingSenderId: "83962234234322"
};
firebase.initializeApp(config);
firebase.datetbase().ref('/employee/').push({
med_number: Math.floor(Math.random() * 1000),
full_name: 'John Smith',
date_employed: Date.now(),
email: '23432432@yahoo.com',
phone_number: '+123423423',
profile_picture : 'blah.img'
}).catch(function(err){
console.log(err);
});
if (event.session.new) {
onSessionStarted({ requestId: event.request.requestId }, event.session);
}
if (event.request.type === 'LaunchRequest') {
onLaunch(event.request,
event.session,
(sessionAttributes, speechletResponse) => {
callback(null, buildResponse(sessionAttributes, …Run Code Online (Sandbox Code Playgroud) javascript node.js firebase aws-lambda firebase-realtime-database
出于某种原因,我很难将这个 txt 文件转换为实际的 javascript 数组。
我的Json.txt
{"action": "key press", "timestamp": 1523783621, "user": "neovim"}
{"action": "unlike", "timestamp": 1523784584, "user": "r00k"}
{"action": "touch", "timestamp": 1523784963, "user": "eevee"}
{"action": "report as spam", "timestamp": 1523786005, "user": "moxie"}
Run Code Online (Sandbox Code Playgroud)
目前我所拥有的不起作用
const fs = require('fs');
function convert(input_file_path) {
const file = fs.readFileSync(input_file_path, 'utf8');
const newFormat = file
.replace(/(\r\n\t|\n|\r\t)/gm,'')
.replace(/}{/g, '},{');
console.log([JSON.parse(newFormat)]);
}
convert('myJson.txt');
Run Code Online (Sandbox Code Playgroud) 嘿伙计们我有一个小问题.
有人可以告诉我如何将这个字符串分成json格式的数据吗?
one:apple;two:orange;three:bananna;four:pears
Run Code Online (Sandbox Code Playgroud)
看起来像这样
{
one: apple,
two: orange,
three: bananna,
four: pears
}
Run Code Online (Sandbox Code Playgroud) javascript ×5
firebase ×2
node.js ×2
algorithm ×1
angular ×1
aws-lambda ×1
ecmascript-6 ×1
iterator ×1