草庐IT

firebase-cloud-functions

全部标签

javascript - '类型错误 : undefined is not a function' when jumping 'tween modules

我在Node中不断遇到这个问题,每当我相互调用函数时,我的应用程序就会崩溃。我已经做了这个最小的工作示例(按照它的方式工作给了我错误):启动模块varmodule2=require('./module2');vardata='data';module2.doStuff(data);模块2varmodule3=require('./module3');functiondoStuff(data){//Stuffhappensto'data'module3.takeStuff(data);}functiondoSomethingElse(data){console.log(data);}mo

javascript - Firebase JS - getToken() 不返回 token

我有以下代码,基于Google'sDocumentation:varconfig={apiKey:"XX",authDomain:"XX",databaseURL:"XX",storageBucket:"XX",messagingSenderId:"XX"};firebase.initializeApp(config);constmessaging=firebase.messaging();messaging.requestPermission().then(function(){console.log('Notificationpermissiongranted.');messagi

javascript - 使用规则禁用 Firebase Cloud Firestore 中的查询集合

我正在使用FirebaseCloudFirestore,我想修改我的规则以限制用户查询集合。这是不允许的:firestore().collection("users").get()但这应该被允许:firestore().collection("users").doc("someUserId").get()目前,我的规则是这样的:match/users/{userId}{allowread;}但是这条规则允许查询“users”集合。如何允许单个文档获取,但不允许集合查询? 最佳答案 您可以将读取规则分解为get和list。get规则适

javascript - JSHINT:如何禁用匿名 'function' 后缺少空格的警告

我在jshint中收到了警告'[L76:C24]Missingspaceafter'function''我遵循NicholasZakkasMaintainablejavascript风格,匿名函数后没有空格。如何在jshint中删除此警告?.jshintrc{"node":true,"browser":true,"es5":true,"esnext":true,"bitwise":true,"camelcase":true,"curly":true,"eqeqeq":true,"immed":true,"indent":4,"latedef":true,"newcap":true,"n

javascript - 类型错误 : module is not a function AngularJS & Jasmine

在我的示例应用程序中,我像这样测试运行器收藏夹Controller:varmodule=angular.module('AngularSampleApp',[]);varFavoritesController=module.controller('FavoritesController',functionfavoritesController($scope){$scope.phones=[{'name':'NexusS','snippet':'FastjustgotfasterwithNexusS.'},{'name':'MotorolaXOOM™withWi-Fi','snippet

javascript - D3 : use nest function to turn flat data with parent key into a hierarchy

我确信有一种非常简单优雅的方法可以做到这一点,但我不太明白。我有一些看起来像这样的输入数据:[{id:1,name:"Peter"},{id:2,name:"Paul",manager:1},{id:3,name:"Mary",manager:1},{id:4,name:"John",manager:2},{id:5,name:"Jane",manager:2}]如果可能,我想使用d3.js嵌套运算符来获取要在层次结构布局中使用的结构。像这样:[{name:"Peter",children:[{name:"Paul",children:[{name:"John"},{name:"Jan

javascript - Dropzone.js init function() 未被调用

我有这个HTML:RemoveAll和$(document).ready(function(){}中的这个Javascriptwindow.Dropzone;Dropzone.autoDiscover=false;$('#fbDropZone').dropzone={init:function(){fbDropZone=this;$("#removeAllImages").click(function(){fbDropZone.removeAllFiles();})},paramName:"file",maxFilesize:5,maxFiles:1,autoProcessQueue:

javascript - Underscore.js _.isObject = function (obj) { return obj === Object(obj); };

当我们查看Underscore.js源码时,我们可以看到如下内容:_.isObject=function(obj){returnobj===Object(obj);};我知道它有效。但为什么不用这个:_.isObject=function(obj){returntypeofobj==="object";};? 最佳答案 不同之处在于棘手的值null。typeofnull返回'object',这显然很令人困惑,而不是想要的结果。但是,将对象构造函数与null一起使用会导致创建新对象(参见MDN)。这意味着您可以区分对象和null,这是

javascript - gulp karma 测试 TypeError : Server is not a function

尝试使用gulp运行karma以运行测试,但遵循以下示例:https://github.com/karma-runner/gulp-karma我的gulp文件:vargulp=require('gulp');varServer=require('karma').Server;/***Runtestonceandexit*/gulp.task('test',function(done){newServer({configFile:__dirname+'/karma.conf.js',singleRun:true},done).start();});/***Watchforfilechan

javascript - Firebase Cloud Functions https.onCall 已完成,状态代码为 : 204

Firebase函数constfunctions=require('firebase-functions');constadmin=require('firebase-admin');constcors=require('cors')({origin:true});exports.addMessage=functions.https.onCall((data,context)=>{return{text:"Test"};});问题问题是,当我从应用程序调用此函数时,我首先得到完成状态代码:204,然后完成状态代码:200204我怎样才能避免这种情况? 最佳答