javascript

Firebase cloud functions bundled with webpack?

倾然丶 夕夏残阳落幕 提交于 2021-02-20 10:16:55
问题 I've been stuck for a while trying to make a webpack build for my cloud functions files. My project structure: ROOT - FUNCTIONS - DIS - bundle.js // THIS SHOULD BE GENERATED BY WEBPACK - SRC - myCloudFunction.js // SOURCE CODE FOR A CLOUD FUNCTION - entryPoint.js // ENTRY POINT FOR WEBPACK - index.js - package.json - SRC - App.js .babelrc firebase.json webpack.prod.js // THIS BUILDS FOR CLIENT (WORKING FINE) webpack.server.js // THIS SHOULD BUILD FOR THE SERVER (NOT WORKING) My goal is: Write

Firebase cloud functions bundled with webpack?

≡放荡痞女 提交于 2021-02-20 10:16:49
问题 I've been stuck for a while trying to make a webpack build for my cloud functions files. My project structure: ROOT - FUNCTIONS - DIS - bundle.js // THIS SHOULD BE GENERATED BY WEBPACK - SRC - myCloudFunction.js // SOURCE CODE FOR A CLOUD FUNCTION - entryPoint.js // ENTRY POINT FOR WEBPACK - index.js - package.json - SRC - App.js .babelrc firebase.json webpack.prod.js // THIS BUILDS FOR CLIENT (WORKING FINE) webpack.server.js // THIS SHOULD BUILD FOR THE SERVER (NOT WORKING) My goal is: Write

VSCode not showing changes in source control git panel

若如初见. 提交于 2021-02-20 10:12:38
问题 When I make a change to a file in the project folder, the 'SOURCE CONTROL: GIT' panel is not showing the changes unless I type git add . in the terminal. They do show as 'Uncommitted Changes' in Git Graph. You can see this in the below screenshot: I have quit VSCode and reopened it, and made sure to open the project root folder which has the .git file which when opened showed the changes, but after I had committed, pushed, and then made some new changes, they were again not picked up. How can

relative URL not working with axios in node

北城以北 提交于 2021-02-20 10:11:33
问题 On my node server, the following code works axios.get('http://localhost:8080/myPath') // works But relative pathes don't work axios.get('/myPath') // doesn't work I get this error : message:"connect ECONNREFUSED 127.0.0.1:80" port:80 How can I get the relative url work like in the browser ? Relative path should be hitting on port 8080, not 80. Where do I set that on my node server ? 回答1: Create a new instance with custom configuation. like below var instance = axios.create({ baseURL: 'http:/

relative URL not working with axios in node

自闭症网瘾萝莉.ら 提交于 2021-02-20 10:10:35
问题 On my node server, the following code works axios.get('http://localhost:8080/myPath') // works But relative pathes don't work axios.get('/myPath') // doesn't work I get this error : message:"connect ECONNREFUSED 127.0.0.1:80" port:80 How can I get the relative url work like in the browser ? Relative path should be hitting on port 8080, not 80. Where do I set that on my node server ? 回答1: Create a new instance with custom configuation. like below var instance = axios.create({ baseURL: 'http:/

How to import ES6 modules in content script for Chrome Extension

做~自己de王妃 提交于 2021-02-20 10:01:25
问题 In Chrome 61 , support for modules in JavaScript was added. Right now I am running Chrome 63. I am trying to use import / export syntax in Chrome extension content script to use modules. In manifest.json : "content_scripts": [ { "js": [ "content.js" ], } ] In my-script.js (same directory as content.js ): 'use strict'; const injectFunction = () => window.alert('hello world'); export default injectFunction; In content.js : 'use strict'; import injectFunction from './my-script.js';

How to import ES6 modules in content script for Chrome Extension

≯℡__Kan透↙ 提交于 2021-02-20 10:01:02
问题 In Chrome 61 , support for modules in JavaScript was added. Right now I am running Chrome 63. I am trying to use import / export syntax in Chrome extension content script to use modules. In manifest.json : "content_scripts": [ { "js": [ "content.js" ], } ] In my-script.js (same directory as content.js ): 'use strict'; const injectFunction = () => window.alert('hello world'); export default injectFunction; In content.js : 'use strict'; import injectFunction from './my-script.js';

How to filter an array without another array javascript

血红的双手。 提交于 2021-02-20 09:46:43
问题 So far I tried this but it returns unfiltered array: function filterRangeInPlace(array, min, max) { array = array.filter(item => (item >= min && item <= max)); console.log(array); } let arr = [5, 3, 8, 1]; filterRangeInPlace(arr, 1, 4); console.log(arr); 回答1: If it's actually important to do the filtering in-place without creating another array, you have to go sort-of old school and iterate through the array with two indexes, copying values along the way. Every time you hit an element that

Is done required in async Jest tests?

半世苍凉 提交于 2021-02-20 09:42:07
问题 I'm having an argument with a co-worker about done() in Jest tests. He's orders of magnitude more experienced with JavaScript than I am, and I came in after async / await was generally accepted, plus came from a .NET environment, so I was used to it. I write my tests like this: it("should return 200 OK for POST method", async () => { await request(app).post("SOMEENDPOINT") .attach("file", "file") .expect(200); }); He's more used to promises so will write his tests like this: it("should return

Date.getDay() is returning different values [duplicate]

拟墨画扇 提交于 2021-02-20 09:40:10
问题 This question already has answers here : Why does Date.parse give incorrect results? (11 answers) Closed 4 years ago . I feel like I am missing something here. The Date.getDay() method is supposed to return a value from 0-6. 0 for Sunday and 6 for Saturday. Now I have two dates, both are 'Sunday' which should return 0. new Date('1990-11-11').getDay() // returns 6 new Date('2016-1-3').getDay() // returns 0 What is causing the discrepancy? I dare to question the validity of the .getDay() method