Category : get

I have a form with 2 input they both have onchange="fetchajax(…);" but when I look in the network section in chrome inspector, I noticed some weird behaviour…. //javascript fecth looks like this function fetchajax() { fetch("…..php, { method: "POST",}).then(…….); } — this is when the page loads ••• when I enter text in input1 => ..

Read more

I have this fetch request below, and variables data_type and data_subtype. I want to pass the value of data_type and data_subtype in the place of :type and :subtype respectively, without actually writing the variable values in there. fetch(‘http://localhost:3000/feature/type/:type/subtype/:subtype,{ method: ‘GET’, headers: { ‘Content-Type’: ‘application/json’ } }).then(response => response.text()) .then(data => { console.log(data); }) .catch(err => ..

Read more

Anyone know how to get Node.js testing to play nice with express.Router? Example: user.js const express = require("express"); const router = express.Router(); const { requireSignin, isAuth, isAdmin } = require("../controllers/auth"); router.get("/user/:userId", requireSignin, isAuth, read, (req, res) =>{ res.send(200); } }; module.exports = router; user.test.js describe(‘Get user ID’, () => { it(‘should reterive id from list’, ..

Read more

I define a controller which code like bellow : const paymentModel = require("../../models/University"); class PaymentController { async getPaymentList(req , res){ const list = await paymentModel.find() .select("amount description payDate payId" ).limit(20); res.send(list); } router like bellow : const router = require ("express").Router(); const controller = require("../http/controller/PaymentController"); router.get(‘/’ ,controller.getPaymentList); module.exports= router; model : const mongoose = require ..

Read more

Here is a GIF explaining the problem. Queries to the database are made with GET requests. When I make a GET request to pull additional data, all the checkboxes get unchecked. How can I save the checkbox state (session data, local storage) after those GET requests? I only need to hold onto those values in ..

Read more

I have a validation in my site that uses a large table (in csv format). I’ve tried the following code: let styleurl = document.getElementById("isthisthestore"); styleurl = styleurl.getAttribute("data-stylesheeturl") console.log(styleurl); let data; $.ajax({ type: "GET", url: styleurl + "/tambour.csv", dataType: "text", success: function(response) { data = $.csv.toArrays(response); console.log(data); } }); I’m getting the url from an element ..

Read more

This works and pipes downloaded data into a file: const fs = require(‘fs’) await fetch(downloadURL).then(res => { const dest = fs.createWriteStream(‘/tmp/output.xlsx’); res.body.pipe(dest); }); This also works: const buffer = await page.evaluate(({downloadURL}) => { return fetch(downloadURL, { method: ‘GET’ }).then(r => r.text()); }, {downloadURL}); But to read a binary stream inside of page.evaluate(), I need to ..

Read more

User can enter different characters for search. For this reason, errors appear when the user enters characters e.g. / or %. How to send the variable search in a get query? router.get(‘/get/:search’, (req, res) => { Label.aggregate(pipeline) .then(result => { res.json(result); }) .catch(err => { res.status(500).send(err); }); }); in frontend: api.get(`${‘get’}/${search}`); Source: Ask Javascript..

Read more