Posts by Cmte Cardeal • 5,299 points
158 posts
-
0
votes1
answer24
viewsA: How do I place the checkbox next to the label?
Because of your .formulario input where you set width: 300px;, this is also doing its <input type="checkbox" /> had width of 300px, and because your form has a limit of 400px;, this causes…
-
4
votes2
answers73
viewsA: How to declare that an object in a Javascript array is empty
Make a if to verify that the value is equal to '' already help your case. It would look like this in my example below: let vagas = ['Fiat, Placa ABC-0123' , 'Tie Fighter, Placa kill-rebels', '',…
-
4
votes2
answers262
viewsA: Sort string in ascending order according to numeric value
You could use numArray.sort((a,b) => {return a - b}); to order and not have this problem. You order by making a comparison values using the function (a,b) => {return a - b}, where: If the…
javascriptanswered Cmte Cardeal 5,299 -
0
votes1
answer118
viewsA: How to make the Input range dynamically by transforming number by Spellnumber(string)
This error happens basically because you are using document.write() instead of document.getElementById('demu').innerHTML. That one .write() is adding the text at the end of the document, outside the…
-
0
votes1
answer86
viewsA: How do I return a req.body.variable in a Express Rest api in a POST method?
The problem seems to be in your then, in this part: fetch(url, options) .then(resposne => JSON.stringify(resposne)) .then((err, val) => { if(val) { console.log(val) } else { console.log(err) }…
-
1
votes1
answer406
viewsA: React - Dynamic table - Adding and removing rows from the table
Basically, what happened to your code is exhibiting strange behavior, is the fact that you haven’t set a default value for these inputs. Also because, as you said, it is removed correctly from the…
-
0
votes1
answer109
viewsA: Event/method that expects content from an iframe to be fully loaded/rendered
Using a gif animation, we can use CSS to insert a loading animation while iframe is being loaded. Animation will be a gif like background of a class we will use in the div that will contain the…
-
1
votes1
answer73
viewsA: Display a`Section` after 2 minutes of clicking the video play button on Youtube
You could use this youtube iframe API. Basically what you need to do to solve your problem (I hope), and add a script to import this API. Enter it via tag: <script data-js="yt_api"…
-
7
votes2
answers573
viewsA: Global variable returns Undefined when using this in Node.js
I want to contribute to the question and will perhaps add in the @hkotsubo reply. I will begin my answer with a question: Why the code below requires more time to run in the Chrome browser than in a…
-
0
votes1
answer80
viewsA: Test api Nodejs Rest with mocha and chai. Post getting pending
Good that you posted the link to your complete code, it was easy to realize the error. Simple error, you closed a parenthesis before the time in the following code: describe("Teste POST game", ()…
-
0
votes1
answer37
viewsA: How to generate a random number only once? (Javascript)
This is a question of where the code is located. When you submit the form, it executes everything inside stopEventSubmit, then every time you click on the button, a new random number will be…
-
0
votes1
answer35
viewsA: Refresh the page after 3 clicks on the button
You couldn’t write a script for this? In this way: let clicks = 0; function clickFunction() { clicks += 1; if (clicks >= 3) { console.log('Clicou mais de 3 vezes!'); // agora voce executa o…
-
1
votes2
answers119
viewsA: Importing public packages into Deno
UPDATE (26/10/2020) I have gone back to reading the entire Deno documentation, and some questions are beginning to be resolved. I will make updates if you help other people. For this doubt: Deno…
denoanswered Cmte Cardeal 5,299 -
3
votes1
answer102
viewsA: Place menu items inside the div
This happens because of your h1 is with standard behaviour of the type block. The way your code is, to display the nav within your div next to the h1, you could add a display: flex: in your class…
-
0
votes1
answer52
viewsA: Problem in Snake game code
You have made an unnecessary multiplication to the value of food with the grid in: let food = { x: Math.floor(Math.random() * grid) * grid, y: Math.floor(Math.random() * grid) * grid, }; this makes…
javascriptanswered Cmte Cardeal 5,299 -
1
votes1
answer105
viewsA: Format database date for javascript
Assuming that your data come in this format: 2020-10-20, Voce can make (in a very direct way) a split(), soon after a reverse()(see here), and finally do join(). Would look like this: const data =…
-
1
votes2
answers43
viewsA: I cannot access the index of a for inside addeventlistener
This is due to the scope problem of var in your loop where you have the for (var i = 0; i < lis.length; i++), read more about this. But basically what happens is that with each iteration of the…
-
2
votes1
answer88
viewsA: Document.querySelector returns Undefined
Doing the tests here, I think I can solve your problem. Let’s go by part... First, the inputs React has a different behavior than traditional, such as react documentation explains: In HTML, form…
-
0
votes1
answer68
viewsA: Take data from an xlsx file
I think the problem is because the onreadystatechange is asynchronous, meaning your code will run from top to bottom synchronously, while the onreadystatechange it will take a while to be called,…
-
2
votes1
answer56
viewsA: Function Result Displayed in Multiple Lines
Following the comment of Rafael Tavares, you can make a function that performs a loop forEach in his state.transacoes and with each loop iteration, we will increment the value of a variable called…
reactanswered Cmte Cardeal 5,299 -
0
votes2
answers111
viewsA: How to do localStorage.setItem('nameserver', 'value') and make the nameserver always change if there is already one with the same name?
I hope to help in your doubt. I will try to show a solution, perhaps complementary or alternative to the @pedro_andrade, which we will create a manual script in an imperative way, since the…
javascriptanswered Cmte Cardeal 5,299 -
1
votes1
answer90
viewsA: How to delete all FK records by deleting their "owner" with Sequelize?
In that case (one for many - N:M) would be assign to the onDelete the value CASCADE, where now, when the user is removed, all properties (user related) will also be removed. user_id: {…
-
2
votes1
answer101
viewsA: Are there advantages to using closures to maintain state rather than class?
This article How to decide between classes v. closures in Javascript explains from a direct and with examples, the differences between closures and class in JS, but I will put here a summary of what…
-
0
votes1
answer152
viewsA: How do I join texts in a Textarea with Js?
That answer explains the difference between innerHTML and the innerText. In your situation, I think you should use value instead of innerText, for the textarea has input behavior. To break the Voce…
-
0
votes1
answer124
viewsA: Sequelize GEOMETRY type field
then, from what I saw in the source code, put in your type the following: Sequelize.GEOMETRY('POINT') // letras em caixa alta. This will indicate a 2-dimensional geometry. Remembering that as the…
-
2
votes2
answers71
viewsA: position elements on a grid
There in his .item4 , create a separate rule and place: .item4 { grid-column: span 2; text-align: left !important; border-radius: 70px !important; } grid-column: span 2; causes the element 0 occupy…
-
1
votes1
answer123
viewsA: Typeerror: Contacts.map is not a Function
I solved your problem, I think, by putting a interface to the Response, and in the setContacts we put response.data.results. In this way: interface ContactsProps { id: number; nome: string; email:…
-
0
votes1
answer46
viewsA: How to add multiple divs to HTML with javascript without replacing already created ones
Basically the problem is in the structure of your code, we will only keep it as is, just put window.onload = init(), performing the function init() for when the window. Now Voce could rewrite if…
-
4
votes2
answers119
viewsQ: Importing public packages into Deno
I was looking at some examples of code in the new Deno, and something caught my attention and caused me some discomfort. It was the way public packages are imported by Deno, through a URL. I know…
denoasked Cmte Cardeal 5,299 -
0
votes1
answer37
viewsA: Repeating structure - 10% "every day"
Your calc has fixed value throughout the loop time. You have to update the calc every iteration of the loop, as calc is R$5 at the beginning, for when the percentage is 10%, at each loop this…
-
0
votes1
answer574
viewsA: Javascript tabulated - a simple way to write it
This code has the following output, assuming that you want to create a table for any number of passings. function tabuada(...args) { for (const number of args) { construirTabuada(number); } }…
javascriptanswered Cmte Cardeal 5,299 -
0
votes1
answer196
viewsA: Creating Migrations using module.Exports
the export default should be used when Voce only export a single value, function, object. see here. what perhaps Voce should do, or try to, use the export. for the methods up and down, and put the…
-
0
votes1
answer236
viewsA: Error installing React Native on linux Mint
This error may be caused because of the version of npm that Voce is using(v3.5.2). Try updating your npm with the command npm install -g npm@latest and try to execute the command again. In case your…
-
2
votes1
answer2216
viewsA: Table filter by name in React
Well, doing some tests here, I think I figured out your mistake. First, let’s redo this input as follows: <input className="form-input" onChange={handleInput} // nao precisa colocar {() =>…
-
1
votes3
answers775
viewsA: What are the ".d.ts" files?
It serves to provide type information in API written in Javascript. For example, using a Jquery in its code, Voce uses this type of file for this, instead of rewriting the entire Jquery into TS, you…
-
2
votes1
answer500
viewsA: What is npm @types and how do they work?
This package in scope @types is where we can find several useful type definitions, such as the Node type definitions that allow us to use, for example, the require to import modules. The package…
-
1
votes1
answer66
viewsA: Insert an information into two Collections in Mongodb with Node.js
You shouldn’t be using the async/await in his function inscricaoCurso? In his model of Participantes, it depends on the id of the model inscreverCurso which is not yet saved because it is an…
-
2
votes1
answer623
viewsA: select sequelize performs different query of parameters passed with datetime
When using Sequelize, it is possible that a problem occurs when recovering the time database. Sequelize converts the date time to UTC time. And as if sequelize recognizes the time in the input field…
-
3
votes1
answer345
viewsA: Why does the express session return 'Undefined'?
Two things: First I think in the cookie config, the field secure should be adjusted to false, at least that’s what I realized in my code. It worked and saved the session when the secure: false. The…
-
1
votes1
answer119
viewsA: How do you protect a stateless API built on the Adonis framework against CSRF and XSS attacks?
I had the same question when I created two applications using EXPRESS, one on the MVC architecture and the other on REST API. Basically, if Voce chooses a path (MVC or REST), it prevents you from…
-
3
votes1
answer672
viewsA: Doubt Sequelize Node.js
Yes, Sequelize will create the table, in your case, userss with one more s in the end, because by default, Sequelize pluralizes the name of all created tables. To leave the table name in the…
-
1
votes1
answer370
viewsA: When to close a postgres pool at Nodejs?
With the own documentation of the Node-postgres,the pool.end() drains the pool of all active customers, disconnects them and closes any internal timer in the pool. This is used in web applications…
-
3
votes1
answer402
viewsA: How to change pages through nodejs?
If you do not understand what Augusto Vasques commented, solve this way: In its route code for the post, pass an object as the second argument with the attribute root setting the absolute path to…
-
8
votes1
answer12477
viewsA: Upload image with Axios to a Node.JS server
In Node.js we will use a middleware to handle files for the type multipart/form-data. I use the ladies. For the app.js: const multer = require("multer"); ... ... let upload = multer(); // Esta é a…
-
2
votes1
answer2635
viewsA: I can’t load CSS and Javascript on my Node.js page
Try to adjust the Static the same way Voce did for views only for the folder public and then in the links of the html file, remove the ../public/ of the CSS and Javascript files. It would look like…
-
1
votes2
answers657
viewsA: Redirect page by passing header Authorization
I assume you mean window.Location redirection = 'http://localhost:8081/Projects', however, as far as I know, it is impossible to redirect to a page with custom headers defined, regardless of the…
-
0
votes1
answer1128
viewsA: Pass parameters on express redirect + Node + ejs
You can use an API called connect-flash which allows storing messages that should be informed to the user. When there is an error, Cvoce informs the flash and redirects to a given route and after…
-
1
votes1
answer144
viewsA: Equivalent to sendFile in restify
You can use the API server-Static-restify for sending static files using the method restify.plugins.serveStatic(). I came to read the documentation, looking for a method similar to Express, but I…
-
4
votes3
answers1959
viewsA: Where should I really keep my JWT token?
Browser localStorage (or session storage) is not secure. Any stored data may be vulnerable to scripts between sites. If an attacker steals a token, he can access and request your API. If the…
-
7
votes1
answer4672
viewsA: How to use SQL "LIKE" in Sequelize?
You can use the operator Op.like from Sequelize to make more complex queries. It would look like this: const Op = Sequelize.Op; // biblioteca de operadores const query = `%${req.query.search}`; //…