frontend

How to interact with back-end after successful auth with OAuth on front-end?

爷,独闯天下 提交于 2020-08-20 18:00:30
问题 I want to build small application. There will be some users. I don't want to make my own user system. I want to integrate my application with oauth/oauth2.0. There is no problem in integration of my front-end application and oauth 2.0. There are so many helpful articles, how to do this, even on stackoverflow.com. For example this post is very helpful. But. What should I do after successful authorization on front-end? Of course, I can just have flag on client, which says "okay, mate, user is

Nodejs Pagination

杀马特。学长 韩版系。学妹 提交于 2020-08-11 00:14:09
问题 I want to make a pagination with Nodejs and Mongoose. I can limit the posts but I couldn't handle the connection of front-end to back-end. this is app.js: app.get('/', function (req, res) { var perPage = 2 var page = req.params.page || 1 Metin .find({}) .skip((perPage * page) - perPage) .limit(perPage) .exec(function(err, metins) { Metin.count().exec(function(err, count) { if (err) return next(err) res.render('index', { metins: metins, current: page, pages: Math.ceil(count / perPage) }) }) })

Cancelling requestAnimationRequest in a React component using hooks doesn't work

…衆ロ難τιáo~ 提交于 2020-07-22 06:06:13
问题 I am working on a progress bar (Eventually..) and I want to stop the animation (calling cancelAnimationRequest ) when reaching a certain value (10, 100, ..., N) and reset it to 0. However, with my current code, it resets to 0 but keeps running indefinitely. I think I might have something wrong in this part of the code: setCount((prevCount) => { console.log('requestRef.current', requestRef.current, prevCount); if (prevCount < 10) return prevCount + deltaTime * 0.001; // Trying to cancel the

Using a video as a background

柔情痞子 提交于 2020-07-21 03:03:15
问题 I want to know which is a good way to use a video as a background, like is used for example in Square Cash: https://square.com/cash 回答1: <div id="video-container"> <video autoplay loop poster="http://media.w3.org/2010/05/sintel/poster.png" muted="muted"> <source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4"> <source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm"> <source id="ogv" src="http://media.w3.org/2010/05/sintel

Using a video as a background

冷暖自知 提交于 2020-07-21 02:59:04
问题 I want to know which is a good way to use a video as a background, like is used for example in Square Cash: https://square.com/cash 回答1: <div id="video-container"> <video autoplay loop poster="http://media.w3.org/2010/05/sintel/poster.png" muted="muted"> <source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4"> <source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm"> <source id="ogv" src="http://media.w3.org/2010/05/sintel

connect and withRouter issue

≯℡__Kan透↙ 提交于 2020-07-16 20:07:07
问题 I am using Redux and React for my project. I have some Routes in App.js. I also use the connect function in react-redux in my project. To prevent update blocking issue, I usually wrapped my component in this way withRouter(connect(mapStateToProps, mapDispatchToProps)(App)), However, If I changed order of withRouter and connect it doesn't work: connect(mapStateToProps, mapDispatchToProps)(withRouter(App)) I have console.log the props in App.js. It already receives location and history props. I

connect and withRouter issue

孤者浪人 提交于 2020-07-16 20:03:05
问题 I am using Redux and React for my project. I have some Routes in App.js. I also use the connect function in react-redux in my project. To prevent update blocking issue, I usually wrapped my component in this way withRouter(connect(mapStateToProps, mapDispatchToProps)(App)), However, If I changed order of withRouter and connect it doesn't work: connect(mapStateToProps, mapDispatchToProps)(withRouter(App)) I have console.log the props in App.js. It already receives location and history props. I

Facebook Pixel slows down page load time by almost a full second

為{幸葍}努か 提交于 2020-06-28 04:50:29
问题 I'm starting to optimize and I have this problem with the Facebook tracking pixel killing my load times: Waterfall Report My page finishes around 1.1 seconds but the pixel doesn't finish until almost a full second later. My pixel script is in the head, per the docs. Is there any way of speeding this up? 回答1: The script probably doesn’t necessarily need to be in the head, even if Facebook recommends that as the default. As long as you don’t explicitly call the fbq function anywhere before the

use fetch to load paginated data recursively

假装没事ソ 提交于 2020-06-27 06:11:55
问题 I would like to fetch data from this API: "https://swapi.co/api/planets". The data is paginated like https://swapi.co/api/planets/?page=1, https://swapi.co/api/planets/?page=2.... I want to build an API which accepts url, page, and callback as arguments. It will fetch all of the data page by page, until it reaches the page specified in the arguments. E.g. function loadData(https://swapi.co/api/planets, 5, cb) this will load data from page1, page2, page3, page4 and page5. Here is my attempt

Should I enable Gzip on Nginx server with SSL for a react app?

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-25 04:12:36
问题 I have a react app with a pretty large build size, it is deployed on an Nginx server with SSL. I learned a bit about GZip and how it can improve the site's performance. But I also came to know that it is not to safe to use GZip with SSL. GZip is enabled for HTML files by default in Nginx. Should I enable it for other files like Javascript and CSS as well to improve performance ? 回答1: When you say it is not to safe to use GZip with SSL i assume that you are talking about Breach Attack. Well