Using await keyword with promisify for cypress.io

I just tried to use await with promisify library.
I put my code below.

import promisify from ‘cypress-promise’;

describe('My First Test', () => {
  it('Does not do much!', async() => {
    const url = "https://rahulshettyacademy.com/seleniumPractise/#/";
    cy.visit(url);
    cy.get(".search-keyword").type("ca");
    cy.wait(2000);
    cy.get(".products").find(".product").should("have.length", 4);
    cy.get(".products").find(".product").each(async($el, index, list) => {
      const element = cy.wrap($el);
      const txtElement = await promisify(element.find(".product-name"));
    });
  })
})

On this line const txtElement = await promisify(element.find(".product-name")); my code gives below error.

`CypressError: cy.each() timed out after waiting 4000ms.

Your callback function returned a promise that never resolved.

The callback function was:

() => {
          const ret = fn.call(ctx, el, index, subject); // if the return value is false then return early

          if (ret === false) {
            endEarly = true;
          }

          return ret;
        }

    at <unknown> (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139277:83)
From previous event:
    at thenFn (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139276:13)
    at yieldItem (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139662:16)
From previous event:
    at Context.each (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:139667:62)
    at wrapped (https://rahulshettyacademy.com/__cypress/runner/cypress_runner.js:157859:19)
From Your Spec Code:
    at eval (webpack:///./cypress/integration/examples/Test1.spec.ts:14:41)
    at step (https://rahulshettyacademy.com/__cypress/tests?p=cypressintegrationexamplesTest1.spec.ts:129:23)
    at Object.eval [as next] (https://rahulshettyacademy.com/__cypress/tests?p=cypressintegrationexamplesTest1.spec.ts:110:53)
    at eval (https://rahulshettyacademy.com/__cypress/tests?p=cypressintegrationexamplesTest1.spec.ts:104:71)
at new Promise (<anonymous>)
    at ./cypress/integration/examples/Test1.spec.ts.__awaiter (https://rahulshettyacademy.com/__cypress/tests?p=cypressintegrationexamplesTest1.spec.ts:100:12)
    at Context.eval (webpack:///./cypress/integration/examples/Test1.spec.ts:4:26)`

Cypress Version
11.2.0

cypress-promise version
^1.1.0

Node version
18.12.1

Operating System
Windows 10 Pro – 21H2 – OS Build 19044.2311

Optimizaiton For Mobile Device

Below is the code I’ve been using to create a website. I’m in the process of getting it online but I am having trouble accessing it on a mobile device using the mobile network. No problems viewing the website using wi-fi, but on a mobile device the site will crash and none of the links will work.

On some web pages, I have a large number of photographs. Could this issue be solved via lazy loading of the photos on the page? Is there any script in the CSS or Javascript that’s making the website difficult to use on a mobile device? Any knowledge about trying to solve this issue would be much appreciated.

<!DOCTYPE html>
<html lang="en">  
    
<meta name="viewport" content="width=device-width, initial-scale=1.0;" charset="utf-8">
    
<body>
    
<style>html{visibility: hidden; opacity: 0;}</style>
    
<title>MORIKOBOSHI・</title>
      
<div class="page-wrap">
     
<div class="cp_cont">
<input id="cp_toggle03" type="checkbox"/>
<div class="cp_mobilebar">
<label for="cp_toggle03" class="cp_menuicon">
<span></span>
</label>
</div>
<label id="h-menu_black" class="cp_toggle03" for="cp_menuicon"></label>
<div id="body" class="noscroll"></div>
        
<header class="cp_offcm03">
        
<nav>
<ul style="text-align: center; margin-left: 210px; overflow: hidden;">
            
<li style="border-bottom: .05px solid lightgray;"><a href="#">Home</a></li>
<li style="border-bottom: .05px solid lightgray;"><a href="#">Blog</a></li>
<li style="border-bottom: .05px solid lightgray;"><a href="#">About This Website</a></li>
<li style="border-bottom: .05px solid lightgray;"><a href="#">Bibliography</a></li>
    
            
<div class="searchbar"> 
            
<form id="frmSearch" class="search2" method="get" action="default.html" style=" padding-right: 10px; padding-top: 20px; text-align: center; position: inline;">
<input class="search2" id="txtSearch" type="text" placeholder="Custom Google Search" name="serach_bar" size="31" maxlength="255" value="" style="top: 185px; width: 180px; height: 26px;">
<input class="search1" type="submit" name="submition" value="Search" style="padding-left: 5px; top: 153px; height: 25px; width: 50px; display: inline-flex; justify-content: center;">
<input class="search2" type="hidden" name="sitesearch" value="default.html">    

</form>
</div>    

    
<script type="text/javascript">
 document.getElementById('frmSearch').onsubmit = function() {
 window.location = 'http://www.google.com/search?q=site:morikoboshi.com' + document.getElementById('txtSearch').value;
        return false;
    }
 
</script>


<script>
 document.getElementById('cp_toggle03').onchange = function() {
 if (document.getElementById('cp_toggle03').checked) {
 document.body.style.overflow = "hidden";
  } else {
 document.body.style.overflow = "";
  }
} 

</script>

</ul>    
</nav>
</header>     
               
<div class="setsumei">
    
 <br><br><h1 style="text-align: center; font-size: 40px;">◯◯◯◯</h1>
    <br><p style="text-align: justify; font-size: 16px;"></p>
    
 <p style="text-align: center; font-size: 13px;">Author: ◯◯◯◯</p>
 <p style="text-align: center; font-size: 13px;">Photos/Videos Taken:◯◯◯◯/◯◯/◯◯</p>
    
 <br><br><p style="text-align: justify; font-size: 16px;">    
    
    #
 </p>    
        
</div>
        
<br><br><div class="image">
    
  <a href="#"><img src="#" alt="#" width="90%"></a>
 
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
    
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
 
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
    
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
    
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
    
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
    
 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>
    
</div>
    
<br><br><footer class="site-footer" style="font-size: 12px;">MORIKOBOSHI© | <a href="#">日本語</a></footer>

</div>
</div>
      
<style>
    
html {visibility: visible;
      opacity: 1;}
    
.body{background-color: white;
      font-family: sans-serif;}
    
 .searchbar{float: right;}
    
 .image{text-align: center;}
    
 .setsumei{margin-left: 20px;
           margin-right: 20px;}
    
 .footer{width: 100%; 
           height: 40px; 
           text-align: center;
           border-top: 1px solid black; 
           position: absolute;
           bottom: 0;
           padding: 10px;}
    
 .page-wrap {
  min-height: 100%;
  /* equal to footer height */
  margin-bottom: -40px; 
}

 .page-wrap:after {
  content: "";
  display: block; 
  }

 .site-footer, .page-wrap:after {
  /* .push must be the same height as footer */
  height: 20px; 
}

 .site-footer {
  text-align: center;
  border-top: 1px solid black;
  padding: 10px;
}
        

 *, *:before, *:after {
    padding-left: 0;
    margin: 0;
    box-sizing: border-box;
    
}    

 ol, ul {
    list-style: none;
}

 a {
    text-decoration: none;
    color: black;
}
    
 .cp_cont {
    height: auto;
}
    
/* menu */
 .cp_offcm03 {
    position: relative;
    z-index: 5000;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    width: 100%;
    height: auto;
    padding-top: 0;
    -webkit-transition: transform 0.3s ease-in;
            transition: transform 0.3s ease-in;
    text-align: center;
    color: black;
    background-color: white;
}
 .cp_offcm03 nav,
 .cp_offcm03 ul {
    height: 100%;
}

 .cp_offcm03 li {
    display: inline-block;
    margin-right: -6px;
}

 .cp_offcm03 a {
    display: block;    
    padding: 15px 45px;
    margin-bottom: -5px;
    -webkit-transition: background-color .3s ease-in;
            transition: background-color .3s ease-in;
}
    
 .cp_offcm03 a:hover {
    background-color: lightgray;
}

/* menu toggle */
 #cp_toggle03 {
    display: none;
}

 #cp_toggle03:checked ~ .cp_offcm03 {
    -webkit-transform: translateX(0);
                    transform: translateX(0);
}

 #cp_toggle03:checked ~ .cp_container {
    -webkit-transform: translateX(0);
                    transform: translateX(0);
}

 .cp_mobilebar {
    display: none;
    
}

/* content */
 .cp_container {
    position: relative;
    top: 0;
    padding: 35px auto;
    -webkit-transition: transform .3s ease-in;
            transition: transform .3s ease-in;
}   

 .cp_content {
    margin: 0 auto;
    padding: 20px;
    height: 65vh;
    text-align: center;

}

@media (max-width: 1130px)and (min-width: 280px) {
/* menu */
 .cp_offcm03 {
        position: fixed;
        left: -250px;
        overflow-y: hidden;
        width: 250px;
        height: 100%;
        padding-top: 40px;
        color: black;
        background-color: white;
        z-index: 1000;
    }
    
    
 .cp_offcm03 nav {
        background: white;
        border-right: 0.5px solid lightgray;
        margin-left: -210px;
    }
    
    
    
 .cp_offcm03 li {
        display: block;
        margin-right: 0;}

        
        
 .cp_offcm03 a {
        padding: 20px;
        
    }
    
/* menu toggle */
 .cp_mobilebar {
        display: block;
        z-index: 2000;
        position: relative;
        top: 0;
        left: 0;
        padding: 0 25px;
        width: 100%;
        height: 40px;
        background-color: white;
        border-bottom: .05px solid lightgray;
        
        
    }
    
 .cp_menuicon {
        display: block;
        position: relative;
        width: 25px;
        height: 100%;
        cursor: pointer;
        -webkit-transition: transform .3s ease-in;
                transition: transform .3s ease-in;
    }
 .cp_menuicon > span {
        display: block;
        position: absolute;
        top: 55%;
        margin-top: -0.3em;
        width: 100%;
        height: 0.2em;
        border-radius: 1px;
        background-color: black;
        -webkit-transition: transform .3s ease;
                transition: transform .3s ease;
    }
 .cp_menuicon > span:before,
 .cp_menuicon > span:after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 1px;
        background-color: black;
        -webkit-transition: transform .3s ease-in;
                transition: transform .3s ease-in;
    }
    
 .cp_menuicon > span:before {
        -webkit-transform: translateY(-0.6em);
                transform: translateY(-0.6em);
    }
 
 .cp_menuicon > span:after {
        -webkit-transform: translateY(0.6em);
                transform: translateY(0.6em);
    }

 #cp_toggle03:checked + .cp_mobilebar .cp_menuicon { 
        -webkit-transform: rotate(45deg);
                transform: rotate(45deg);
    }
    
 #cp_toggle03:checked + .cp_mobilebar span:before,
 #cp_toggle03:checked + .cp_mobilebar span:after {
        -webkit-transform: rotate(90deg);
                transform: rotate(90deg);
    }
    
 #cp_toggle03:checked ~ .cp_offcm03 {
        -webkit-transform: translateX(100%);
                transform: translateX(100%);
    }
    
 #cp_toggle03:checked ~ .cp_container {
        -webkit-transform: translateX(250px);
                transform: translateX(250px);
    }
    
 input:checked ~ #h-menu_black {
    display: block;/*カバーを表示*/
    opacity: .6;
}
    
 #h-menu_black {
    display: none;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    transition: .7s ease-in-out;
}
    
/* content */
 .cp_container {
        top: 60px;
        height: 92vh;
        text-align: center; 
    } 
    
 .noscroll{
        overflow: hidden;
        position: fixed;
    }
    
</style> 
      
</body>
</html>

How to decompress an API response in EXPRESS JS? The API returned weird symbols

I am doing a project and the API response returned some strange symbols instead of the expected JSON format.

Looks like this:

�Ymk��+�~����tO�t�����H�ec��0=3�ڱvg��E�0�p��Kr� !݇��$!        B��
                           $?E�}���ٕٗٙtg�@
  b�VUWw�S/=O:��Hw�;�Z�E�7��@y����q�������^qP$����|��t�$Gh�;�Q�ԢB �������T����u

But much longer.

My code is this:

const express = require("express");
const cors = require("cors");
const axios = require("axios");
require("dotenv").config();

const PORT = process.env.PORT || 3000;


// init express
const app = express();

// enable cors
app.use(cors());

//routes
app.get("/api/search/:query", async (req,res)=>{
    try {
        const query = req.params.query;
        const results = await axios(`https://api.mapbox.com/geocoding/v5/mapbox.places/${query}.json?limit=10&access_token=${process.env.API_KEY}`) 
        console.log(results.data)
    } catch (error) {
        res.status(500).json({ error: error.message });
      }
})

app.listen(PORT, () => console.log(`app started on port: ${PORT}`));

If you know how to decompress the api and help me telling me where should I add it on my code, I would be very thankful.

🙂

I found out it’s because the API is responding the information compressed, so I have to decompress it on my code. I found several ways of doing it, but I couldn’t find an aswer that I could make it works on my code.

Calculations in Javascript

When I check the ckeckbox the total.value increases incorrectly and when I uncheck the box the value does not decrease.

JavaScript

function subTotalEntry() {
  let total = document.getElementById('entryTotal');

  let price = document.querySelector('.first-entry').innerHTML;
  
  let qty = document.querySelector('.entryQty').checked;
    
  let cageSize = document.querySelector('.firstCageSize').value;
  
  let smCagePrice = document.querySelector('.small-cage').innerHTML;
  
  let lrgCagePrice = document.querySelector('.large-cage').innerHTML;
  
  if (qty && cageSize == 'small') {
      total.value = Number(total.value) + Number(price) * Number(qty) + Number(smCagePrice);
  } else if (qty && cageSize == 'large') {
      total.value = Number(total.value) + Number(price) * Number(qty) + Number(lrgCagePrice);
  } else if (qty && cageSize == 'BYO') {
      total.value = Number(total.value) + Number(price) * Number(qty);
  } else {
      total.value = Number(total.value) + Number(price) * Number(qty);
  }
  console.log(total.value);
  grandTotal();

}

I have tried without the Number(total.value) in each if statement. Can someone please help?

Trying to print numbers in Jquery but rather than integers, I recieve [Object object]

I am attempting to create a Calender using Jquery. But I don’t understand how to have my object print the value it contains. I tried JSON.toString() on my table data but it did not correct my issue. Maybe I am misplacing the toString method in my code?

Before toString:

// get the number of days in the month
let daysInMonth = new Date(this.displayDate.getFullYear(), this.displayDate.getMonth() + 1, 0).getDate();

// get array of days to display
let days = [];
for (let i = 1; i <= daysInMonth; i++) {
  days.push(new Date(displayDate.getFullYear(), displayDate.getMonth(),i));
}

 console.log(this.monthNames[this.displayDate.getMonth()] + " " + this.displayDate.getFullYear());

td = $("<td>").attr("class", "day").text(days[i].getDate());
td.append(td);

Based on this Firefox Javascript guide [object, object] is corrected using the JSON.toString() method. But when I implemented it

      td = $("<td>").attr("class", "day").text(days[i].getDate());
      td.append(JSON.stringify("td"));

JSFiddle is here.

Search highlight text using regex is throwing error

Here’s an example of a list of products and a search filter:

jQuery( document ).ready( function( $ ) {
    $( '#discount-products-search' ).on( 'keyup blur', function() {
        let elSearch = $( this );
        let elSearchVal = elSearch.val().toLowerCase();
        
        $( '.discount-products-list .product-item' ).each( function() {
            let _el = $( this );
            let _elA = _el.find( 'a' );
            let _elAText = _elA.text();
            let _elATextLowercase = _elAText.toLowerCase();
            
            if( _elATextLowercase.indexOf( elSearchVal ) > -1 ) {
                _el.show();
                
                _elAText = _elAText.replace( new RegExp( elSearchVal, 'ig' ), ( match, $1 ) => {
                    return '<mark>' + match + '</mark>';
                } );
                
                _elA.html( _elAText );
            }
            else {
                _el.hide();
                
                _elA.html( _elAText );
            }
        } );
    } );
} );
.discount-products-wrapper {
    width: 100%;
}

.discount-products-wrapper p {
    margin: 10px 0 0 0;
}

.discount-products-list {
    max-height: 222px;
    overflow: auto;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    background-color: #f0f0f1;
}

.discount-products-list .product-item {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 15% 10px 85%;
    grid-template-columns: 15% 85%;
    grid-gap: 10px;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

.discount-products-list .product-item:not(:last-child) {
    margin-bottom: 5px;
}

.discount-products-list .product-item img {
    width: 100%;
    height: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="discount-products-wrapper">
                            <input type="search" id="discount-products-search" placeholder="Search...">
                
                <div class="discount-products-list">
                                            <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=702&amp;action=edit" target="_blank">Test Product (Copy) 9</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=699&amp;action=edit" target="_blank">Test Product (Copy) 8</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=696&amp;action=edit" target="_blank">Test Product (Copy) 7</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=693&amp;action=edit" target="_blank">Test Product (Copy) 6</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=690&amp;action=edit" target="_blank">Test Product (Copy) 5</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=687&amp;action=edit" target="_blank">Test Product (Copy) 4</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=684&amp;action=edit" target="_blank">Test Product (Copy) 3</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=681&amp;action=edit" target="_blank">Test Product (Copy) 2</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=678&amp;action=edit" target="_blank">Test Product (Copy) 1</a>
                                                        </div>
                                                <div class="product-item">
                            <img width="150" height="150" src="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png" class="woocommerce-placeholder wp-post-image" alt="Placeholder" decoding="async" loading="lazy" srcset="https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-150x150.png 150w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-300x300.png 300w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-100x100.png 100w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-600x600.png 600w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-1024x1024.png 1024w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder-768x768.png 768w, https://tests.odedta.com/wp-content/uploads/woocommerce-placeholder.png 1200w" sizes="(max-width: 150px) 100vw, 150px">                              <a href="https://tests.odedta.com/wp-admin/post.php?post=23&amp;action=edit" target="_blank">Test Product</a>
                                                        </div>
                                        </div>
        </div>

If I type “test” it works fine, but when I try to type test Product ( I get this error:
Uncaught SyntaxError: Invalid regular expression: /test product (/: Unterminated group (at

I am basically trying to filter our results and highlight them. How can I allow special characters in the filter?

Thanks

How do I add a file to my apk files in order to allow it to execute on app start?

I have an apk of my business and I want to add an extra file to it in order for the code to run when the program starts (when I click the app to open). I’m not sure what type of file I should add because it’s kind of tricky to know.

I tried to add code to one of the files to open a file on start but it didn’t work. Can someone tell me what kind of file to add to the decompiled apk files in order for this to work?

Is it slower if the querySelector is specific?

Is it slower if the querySelector is specific?

I often copy and use the selector with the Chrome Developer Tools.

However, in some Atricle, it was said that if the querySelector is specific, it works more slowly.

Is this true?

document.querySelector('A > B > C > D > E')

document.querySelector('A E')

I wonder if this makes a difference in speed.

I wonder how big the difference is if there is a speed difference.

Where in my code can I put .lowerCase() to make it function?

(I am new to Javascript, still learning!)

I want to make it possible to write both lowercase and uppercase in the search-field.
Where can I put .lowerCase()? I have tried putting it after .value, but it just does not work for me.

Here is my code:

btn.onclick = function () {

  var searchedByUser = subregionTxt.value;

  for (var i = 0; i < countriesAmericaArray.length; i++) {
    if (countriesAmericaArray[i].subregion.includes(searchedByUser)) {
      outputDiv.innerHTML += `
                <h1>${countriesAmericaArray[i].name.common}</h1>
                <p>Antall innbyggere: ${countriesAmericaArray[i].population}</p>
                <p>Subregion: ${countriesAmericaArray[i].subregion} </p>
                <img src="${countriesAmericaArray[i].flag.png}"> 
                `;
    }
  }

  if (!subregionTxt.value) {
    alert("You have to write something!");
  }

};

I want to make it possible to write both lowercase and uppercase in the search-field.
Where can I put .lowerCase()? I have tried putting it after .value, but it just does not work for me.

How to auto-indent code string in PrismJS? NextJs APP

i am trying to use PrimsJs in a react project, my objetive is create a static template page, and add snippets, i am not sure if is the best option(primsjs) but i am trying to auto-indent the code, because actually my code is rendered in one line


enter image description here

THIS IS MY PAGE

import { MainLayout } from "../components/layouts/MainLayout";
import { Hero1, Hero1Code} from "../theme/blocks/hero/Hero1";

export default function Home() {
    return (
        <MainLayout>
            <h1>Home Page</h1>
            <Hero1 />
            <Hero1Code />
        </MainLayout>
    );
}

THIS IS MY PRIMSJS COMPONENT

import React, { useEffect } from "react";
import Prism from "prismjs";
import "prismjs/themes/prism-tomorrow.css";


export default function Code({ code, language }) {
  useEffect(() => {
    Prism.highlightAll();
  }, []);

  return (
    <div className="Code">
      <pre>
        <code className={`language-${language}`}>{code}</code>
      </pre>
    </div>
  );
}

THIS IS MY COMPONENT

import React from "react";

import { renderToString } from "react-dom/server";
import Code from "../../../components/prism/code";

export const Hero1 = () => {
    return (
        <section className="wrapper bg-light">
           ...
        </section>

    );
};

export const Hero1Code = () => {
    const content = renderToString(<Hero1/>);
    return (
        <>
            <div className="App">
                <Code code={content} language="html" />
            </div>
        </>
    );
};

Any help will be very welcome, also i am open to try other package

Is there a way to “nest” promises when using Promise.allSettled?

I have a Vue SPA that has a array of promises that are being awaited on page load.

const promiseArray = [
ServiceA.method(),
ServiceB.method(),
ServiceC.method(),
...,
ServiceZ.method()
]

Promise.allSettled(promiseArray);

As the application grows more and more complex, some of these promises/services need to complete prior to starting other calls.

For example,

ServiceA Requires ServiceD to finish
or 
ServiceE requires ServiceB to finish

Is there a way to “nest” these async/await calls to keep the simplicity of a singular array and awaiting them all concurrently without introducing a large amount of complexity?

ServiceC THEN ServiceA,
ServiceF THEN ServiceD,

Is there a way to refactor to make the code behave something like this and that could possibly be extended upon to include even more dependcies in the future?

ServiceA THEN ServiceC THEN ServiceQ
ServiceB,
ServiceD
...

Currently I have the dependencies inside of the service code as there is only the one so far, but I have a couple of tickets coming in pipeline that will require more.

I will most likely end up batching these promises and run them one after another, but I was curious if there was a more elegant way.

I’m trying to display the Image after the lotti progress finished and disappeared but I couldn’t in react native

Here is my code:

    const Success =({navigation})=>{
     
    

  useEffect(() => {

    setTimeout(()=>{

      <View>
        <Image  source={images.done}
          style={{
             width:100,
            height:100
      }}
      />
    </View>
    navigation.navigate('Home')

    },4000)
  }, [])

    
    return(
        <View style={{
            flex:1,
            justifyContent:'center',
            alignItems:'center',
        }}>
    <LottieView
        style={{
          width: 100,
          height: 60,
        }}
        source={images.progress}
     autoPlay 
      />
        </View>
    )
}


export default Success ;

Please Help me out How I can display first Lotti progress and then immediately I wanna the image done appears after the Lotti progress finish and disappear. so I would know how to set time for Lotti progress and then set time to display the Image done then navigate to the next page