小编Sub*_*ndu的帖子

使用firebase-functions部署基于反应的SSR应用程序时出错

我试图在应用程序中进行一些修改后,最初从https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router分发的firebase中部署我的SSR应用程序.我做的时候工作得很好,sudo firebase serve --only functions,hosting但是当我做的时候会抛出错误firebase deploy.可重复的回购是https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router,它有一个package.json https://github.com/subhendukundu/template-react-ssr/ tree/feature/react-router/public 我也使用公共目录作为我的函数目录,https://github.com/subhendukundu/template-react-ssr/blob/feature/react-router/firebase.json.但是,即使我为我的云功能使用不同的功能目录,我也会看到相同的错误.无论如何我能解决它吗?

firebase reactjs firebase-hosting google-cloud-functions next.js

10
推荐指数
1
解决办法
393
查看次数

如何在 npm 包中添加文件夹作为条目?

我正在尝试发布一个 npm 模块。它具有以下文件夹结构。 在此处输入图片说明

在我package.json看来,"main": "./dist/"我理解这种对index.js. 但是在 dist 文件夹中,我有名为string.js, 的单个文件class.jsdom.js我打算将它们导入为, import { isValidZipCode } from '@scope/utils/string';但现在我必须将它们导入为import { isValidZipCode } from '@scope/utils/dist/string';

当我从中导入模块时,有没有办法解析文件夹node_modules

编辑:主要思想是导入文件,就像import { isValidZipCode } from '@scope/utils/string'我为单个导出保留单个文件一样。

javascript node.js npm node-modules yarnpkg

8
推荐指数
1
解决办法
2756
查看次数

自定义域在带有 serverless-next.js 的 aws 中不起作用?

我面临与Github 问题相同的问题,但适用于不同的用例。我正在尝试添加应用程序的多个实例:此处的示例代码

添加域后,我收到相同的错误:

Domain www.app.com was not found in your AWS account. 
Run Code Online (Sandbox Code Playgroud)

因此,为了实现多个实例,我尝试将 env-prod 文件更改为bucket="prod-appname". 这已部署,但是当我将 env-stage 文件添加到 时bucket="stage-appname",这会创建一个新存储桶,但会将其部署到相同的 CloudFront URL。有没有办法修复它们中的任何一个,以便我可以实现多个实例?

提前致谢

javascript amazon-web-services amazon-cloudfront serverless-framework next.js

8
推荐指数
1
解决办法
353
查看次数

是否可以像 dart 中的 javascript 一样使用 dart 在列表中使用解构和传播?

我已经玩了几天 flutter,还没有掌握它的窍门。在尝试 dart 及其方法时,我开始思考如何让学习曲线更容易开始与 javascript 相关(因为我非常熟悉它,个人选择,人们可能有或使用不同的方法)。

我有一个小疑问,在 dart 中是否可以同时解构和传播?我知道如果不可能,我如何用 dart 实现这样的目标?我试图获取变量中数组的第一项和字符串中的其余数组值,并将它们作为字符串连接起来。我必须遍历所有这些吗?不能以更短或更漂亮的方式(透视)?

// JavaScript
var someArray = ['1', '2' ,'3', '4'];
var [first, ...rest] = someArray;
var restAsString = rest.join(' ');
console.log(first); // 1
console.log(restAsString); // 2 3 4
Run Code Online (Sandbox Code Playgroud)
//dart
main(List<String> arguments) {
  List<String> someList = ['1', '2' ,'3', '4'];
  String restString = '';
  String firstString = '';
  for (int i = 0; i < someList.length; i++) {
    if(i == 0 ) {
      firstString = someList[i];
    } else {
      restString = …
Run Code Online (Sandbox Code Playgroud)

javascript dart flutter

8
推荐指数
2
解决办法
1万
查看次数

如何获得在react-native中在webview中设置的cookie?

我正在尝试检索用户输入的邮政编码,该邮政编码已添加到webview的cookie中。我如何得到它?我试过react-native-cookies哪个是空对象。

import CookieManager from 'react-native-cookies';

componentWillMount() {
    CookieManager.get('https://www.example.com')
    .then((res) => {
      console.log('CookieManager.get from webkit-view =>', res);
    });
  }
}

<WebView
  style={styles.webview}
  source={{ uri: 'https://www.example.com' }}
  injectedJavaScript={INJECTED_JAVASCRIPT}
  mixedContentMode="compatibility"
  javaScriptEnabled
  domStorageEnabled
  thirdPartyCookiesEnabled
  sharedCookiesEnabled
  originWhitelist={['*']}
  useWebKit
/>

Run Code Online (Sandbox Code Playgroud)

我正在iOS模拟器中尝试。Android很棒。我看到https://github.com/react-native-community/react-native-webview/pull/175已合并,但无法弄清楚如何使用它来获取用户设置的cookie。

react-native react-native-ios react-native-webview react-native-cookies

6
推荐指数
1
解决办法
1386
查看次数

Appsync 更新和删除突变不起作用

我正在为我的 APP 使用 AppSync。这是我的 Schema.graphql 文件的快速浏览

type Item @model
  @auth(rules: [
    { allow: public, provider: apiKey, operations: [read] },
    { allow: groups, groups: ["admin"] }
  ]) {
  id: ID!
  name: String!
  soldUnits: String!
  soldAs: [Float!]
  price: Float!
  isAvailable: Boolean!
  availableAmount: Float!
  category: String!
  isVeg: Boolean!
  offer: [String!]
  about: String
  storage: String
  benifits: String
  otherInfo: String
  rating: Int
  keywords: [String!]
  reviews: [String]
  images: [String]
  updatedBy: String
  addedBy: String
  qty: Int
  inventroy: Inventory @connection(name: "ItemInventory")
}

type User @model {
  id: ID! …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services reactjs graphql aws-appsync aws-amplify

6
推荐指数
2
解决办法
2389
查看次数

如何在 angular 2 中使用 Google Sheet API V4?

我正在尝试创建一个要在 Excel 工作表中更新的应用程序。我遇到了https://github.com/dwyl/html-form-send-email-via-google-script-without-server,它显然不适用于 angular。将 ajax 调用替换为

onsubmitForm() {
  let headers = new Headers();
  headers.append('Access-Control-Allow-Origin','*');
  let options = new RequestOptions({ headers: headers });
  let body = {
    name:"lala",
    message:"ssss",
    email:"a@k.com",
    color:"red"
  }
return this.http.put('https://script.google.com/macros/s/AKfycbxJKxvzl8Go5ZihUc95su-HFvFeoTtnMyA3qq5YiBxcDYalDdOb/exec', body).toPromise(); }
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,“对预检请求的响应未通过访问控制检查:没有‘Access-Control-Allow-Origin’”。有办法解决吗?或者可能是使用 angular 2 将数据添加到 Excel 工作表的另一种方法?

angular-cli google-sheets-api angular

5
推荐指数
0
解决办法
2061
查看次数

是否可以在 googlesheet 上保存新数据时触发 google 电子表格 API V4 的事件?

我正在尝试使用 Google 表格 API V4 从 Google 表格中获取数据。是否有可能知道是否有人保存了数据或在工作表上进行了更改?基于此,我想调用 api 以获取数据?更像是我试图让我的应用程序与谷歌表同步。只要有人更新数据,我的应用程序也会更新。我正在使用 Node.js。我怎么做?提前致谢

google-sheets node.js sendasynchronousrequest google-sheets-api

5
推荐指数
0
解决办法
1496
查看次数

如何在react-native中添加破折号或虚线边框?

我想在一侧添加虚线边框,

{
  height: '100%',
  width: 20,
  position: 'absolute',
  borderRadius : 1,
  borderStyle: 'dashed',
  borderRightWidth: 1,
  borderRightColor: 'rgba(161,155,183,1)'
}
Run Code Online (Sandbox Code Playgroud)

这不起作用,但是当我将其更改为

{
  height: '100%',
  width: 20,
  position: 'absolute',
  borderRadius : 1,
  borderStyle: 'dashed',
  borderWidth: 1,
  borderColor: 'rgba(161,155,183,1)'
}
Run Code Online (Sandbox Code Playgroud)

可以工作,但边界在 4 边。如何仅在一侧添加边框?还有没有办法增加破折号的间距? "react-native": "0.57.7"

android ios reactjs react-native

5
推荐指数
1
解决办法
1万
查看次数

如何修复由于React SSR初始化数据库和云功能firebase初始化数据库导致的Firebase数据库多次初始化?

我已经更新了问题,找到了问题的根本原因。当我托管了我的React SSR应用程序时,该应用程序在客户端中使用Firebase数据库,该客户端通过名为的云函数之一app抛出错误Error: FIREBASE FATAL ERROR: Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.。当我逐一注释并部署时,效果很好。但是当我一起部署时不起作用。如何将这两个保持在相同的仓库中分开?

原始问题:Why firebase cloud function throwing an error of 'The default Firebase app does not exist.'? 所以我第一次尝试使用firebase函数。admin.messaging()向我抛出以下错误。帮我弄清楚为什么吗?如果我看一下控制台,我会得到结果,直到console.log('deviceToken', deviceToken);

那么const messageDone = await admin.messaging().sendToDevice(deviceToken, payload);怎么了?

const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.updateUnreadCount = functions.database.ref('/chats/{chatId}/{messageId}')
  .onCreate(async(snap, context) => {
    const appOptions = JSON.parse(process.env.FIREBASE_CONFIG);
    appOptions.databaseAuthVariableOverride = context.auth;
    const adminApp = admin.initializeApp(appOptions, …
Run Code Online (Sandbox Code Playgroud)

javascript node.js firebase google-cloud-functions

5
推荐指数
1
解决办法
241
查看次数