Triggering menu modal upon clicking button (Tailwind)

I have a button that I want to trigger a menu modal. I thought I just needed to set data-modal-toggle="menu-modal" but clearly I am missing something.

Below is my button and the modal I want it to toggle.

        <div className="ml-auto fixed bottom-3">
            <button
            type="button"
            className="inline-flex items-center p-3 border border-transparent rounded-full shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 "
            data-modal-toggle="menu-modal"
          >
            <PlusSmIconOutline className="h-6 w-6" aria-hidden="true" />
          </button>
        </div>


        <Transition.Root show={open} as={Fragment}>
      <Dialog as="div" id="menu-modal" className="relative z-10" onClose={setOpen}>
        <Transition.Child
          as={Fragment}
          enter="ease-out duration-300"
          enterFrom="opacity-0"
          enterTo="opacity-100"
          leave="ease-in duration-200"
          leaveFrom="opacity-100"
          leaveTo="opacity-0"
        >
          <div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
        </Transition.Child>

        <div className="fixed z-10 inset-0 overflow-y-auto">
          <div className="flex items-end sm:items-center justify-center min-h-full p-4 text-center sm:p-0">
            <Transition.Child
              as={Fragment}
              enter="ease-out duration-300"
              enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
              enterTo="opacity-100 translate-y-0 sm:scale-100"
              leave="ease-in duration-200"
              leaveFrom="opacity-100 translate-y-0 sm:scale-100"
              leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
            >
              <Dialog.Panel className="relative bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:max-w-sm sm:w-full sm:p-6">
                <div>
                  <div className="mt-3 text-center sm:mt-5">
                    <Dialog.Title as="h3" className="text-md leading-6 font-medium text-gray-900">
                      Community Name
                    </Dialog.Title>
                    {/* <div className="mt-2">
                      <p className="text-sm text-gray-500">
                        Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.
                      </p>
                    </div> */}
                  </div>
                </div>
                <div className="mt-5 sm:mt-6">
                  <button
                    type="button"
                    className="inline-flex justify-center w-full rounded-md border border-transparent shadow-sm px-4 py-3 my-2 bg-indigo-600 text-base font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:text-sm"
                    onClick={() => setOpen(false)}
                  >
                    Menu Option
                  </button>
             

                </div>
              </Dialog.Panel>
            </Transition.Child>
          </div>
        </div>
      </Dialog>
    </Transition.Root>

Run javascript in backend PHP file [duplicate]

I am trying to run JS code in the backend using PHP but with no success so far.

Problem:
I restricted access to the API of our MVP to the localhost only, and I would like to call the API via Javascript via the backend (since the request would be blocked if called by the frontend). I thought of calling the Javascript script via PHP with the following code:

<?php
echo '<script type="text/JavaScript"> 
        fetch("https://api.example.com:endpoint");
     </script>'
    ;
?>

and added a print in the API to check if the router is being called.

Issue
When loading the page I get no error in console, nor I get a print, so I expect that JS is running on fronend and not backend. Is there a way to make JS code run in backend?

How to properly sort documents in firebase collection from first to last

I want every data sent last to be sorted as the last mongo document in my firebase collection. In any case, the last sent data will be stored as the last document in the collection. I used sorting by dates and current time but it is not effective for all dates. (for example date 2.6 puts first instead of 19.6)

This is my function:

Reservations(){
  this.user = store.currentUser
  this.empty_form=false;
  if(this.current_museum!=''&&this.date!=''&&this.ticket_number!=''&&this.user!='')
  {
  //Date I used for sorting  
  const current = new Date();
  const date = current.getFullYear()+'-'+(current.getMonth()+1)+'-'+current.getDate();
  const time = current.getHours() + ":" + current.getMinutes() + ":" + current.getSeconds();
  const dateTime = date +' '+ time;

  let counter = counter + 1;

  router.replace({path:'/ticket_reserved', replace: true})    
  

  try {
    db.collection("reservations")
        .doc(dateTime)
        .set({
          current_museum: this.current_museum,
          date: this.date,
          ticket_number: this.ticket_number,
          user: this.user
        });
    
  }
  catch(error) {
    
  }
}else{
  this.empty_form=true;
}},

Cannot send data to firebase collection

I’m trying to send data on firebase collection but I can’t figure out why it can’t be sent. Function called createUserWithEmailAndPassword() works normally. In other functions sending data in firebase collection is working fine when I want to send it, but here it doesn’t work for some unknown reason. Is this some bug or what?

My function:

SignUp() {
  firebase
    .auth()
    .createUserWithEmailAndPassword(this.email, this.password);
  try {
    
    const unique = this.email;
    db.collection("user")
      .doc(unique)
      .set({
        name: this.name,
        surname: this.surname,
        email: this.email,
        birth_date: this.birth_date,
        city: this.city,
        phone_number: this.phone_number,
      });
    this.success_register=true;
   catch(error) {
      if ((store.currentUser = null)) this.$router.replace({ name: "signup" });
    }
  
}

how to make false values to true?

this website for testnet , and my walletaddress is not on whitelist when i request the token, so is it possible to make false values to true ?

    var address = $("#token_select").val();
    $("#address").remove();
    var url = "https://testnet.bscscan.com/address/" + address;
    $("#token_address").append('<a href=' + url + ' target="_blank" id="address" class="control-label">' + address + '</a>');
});


$("#request_token").click(function () {
    var token = $("#token_select").val();
    var address = $("#user_address").val();
    var url = $("#request_token").attr('key');
    if (!token) {
        return alert('Please select a token!')
    }
    if (!address) {
        return alert('Please enter your address!')
    }
    fetch(url, {
        method: 'POST',
        body: JSON.stringify({token: token, address: address}),
        headers: {"Content-Type": "application/json"}
    }).then(response => response.json())
        .then(
            result => {
                console.log(result);
                if (result.success) {
                    var url = "https://testnet.bscscan.com/tx/" + result.data;
                    $("#transactions").append('<a href=' + url + ' target="_blank" id="txHash" class="control-label">' + result.data + '</a>');
                } else {
                    alert('Request error: ' + result.error)
                }
            });

});

Nextjs infinite scroll function not loading more data on scrolling

Hello I am struggling to implement infinite scroll from last few days. I used django rest for building my api. Here is my pagination url https://example.com/blog-api/?page=1it will show 2 items per page. Here here my code

const fetchMoreData = async () => {
    let url = `https://backendapi.farhyn.com/blog-api/?page=${count + 1}`;
    SetCount(count + 1);
    const res = await fetch(url);

    const data = await res.json();
    SetBlog(data)
    console.log(data);
  };

 <InfiniteScroll
      dataLength={blog.results.length}
      next={fetchMoreData}
     hasMore={true}
    loader={<h4>Loading...</h4>}
 >{blog.results.map((data) => ( {data.blog_title}   ))}
 </InfiniteScroll>

where I am doing mistake? data not loading on scroll.

JUMPING ON collapsible BUTTON

Dears Greetings,,

I want to jump from Group 1 to Group 3 by clicking on Text on Group 1. ((similar to an anchor link) )
using HTML or JS.

I really hope I can find the solution. I attached the code below

many thanks & best regards

<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Accordion Example</h2>
  <p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p>
  <div class="panel-group" id="accordion">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h4 class="panel-title">
          <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Collapsible Group 1</a>
        </h4>
      </div>
      <div id="collapse1" class="panel-collapse collapse in">
        <div class="panel-body"> <a href="#JumpToGroup3">click here</a> 
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea .</div>
      </div>
    </div>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h4 class="panel-title">
          <a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Collapsible Group 2</a>
        </h4>
      </div>
      <div id="collapse2" class="panel-collapse collapse">
        <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
        sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
      </div>
    </div>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h4 class="panel-title">
          <a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Collapsible Group 3</a>
        </h4>
      </div>
      <div id="collapse3" class="panel-collapse collapse">
        <div class="panel-body"> <b id="JumpToGroup3">JUMP HERE</b> ipsum dolor sit amet, consectetur adipisicing elit,
        sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
      </div>
    </div>
  </div> 
</div>
    
</body>
</html>

Rendering a collection, use an array instead react

I am new to react and feel this might be a basic question

I am trying to get NFTs of the user wallet and trying to map it.

But I am getting the below error

Server Error
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.

Below is my logic

  import Link from 'next/link';
  import { useWeb3Context } from '../../context'
  import { Web3Button } from '../../components';
  import axios from 'axios';
  import React, { useEffect, useState } from 'react';
  import NFTContainer from '@/components/NFTContainer';



  const renderNotConnectedContainer = () => (
      <Web3Button/>
    );


  export const ChooseProductView = async () => {
      const { address } = useWeb3Context()
      

      if(!address){
        return renderNotConnectedContainer()
      }

      else{
        
          const nfts = await axios.get(`https://ethereum-api.rarible.org/v0.1/nft/items/byOwner?owner=${address}`);
      
          console.log(nfts.data)


          return(   
        
              <div className="flex items-center justify-center">
              <div className="border-grey md: w-full rounded-xl border sm:max-w-xl md:max-w-2xl">
                <div className="flex flex-row justify-between py-2 px-6">
                  <span className="md:text-md text-left text-sm font-light lg:text-lg">
                    Address
                  </span>
                  <span className="md:text-md truncate pl-4 text-right text-sm  font-light lg:text-lg">
                    {address}
                  </span>
                </div>
                
                <NFTContainer nfts={nfts}/>

              </div>
              
            </div>
            

            )

      }
      
    };

I am further trying to use map as below

import React from "react";
import NFTCard from "./NFTCard";

const NFTContainer = ({nfts}) => {
return(
    <div>
        {nfts.map((nft:any, index:any) => (
         <NFTCard nft={nft} key= {index}/>
        ))
   
        }
    </div>
    )
}

export default NFTContainer

Thanks in advance

I am making a small web app with an xml file as a database, and I’m getting a nullpointer exception.. Is it because of the Node lists?

After I start the server, I get the NullPointerException. I am trying to make it write data from the web app, and I wonder what the issue is, is it some of the collections(NodeLists) that I’ve been working with, or some of the variables it’s trying to use? I’m also trying to make a table on the HTML document below, to display it once I refresh the page. If anyone can provide any insight or a reference to this I’d be quite grateful.

package com.andrija.crud;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.List;

import org.w3c.dom.*;
import org.xml.sax.SAXException;

import jakarta.servlet.http.*;

    public class Register extends HttpServlet {
    
        private static final long serialVersionUID = 1L;
        private static final int NUMBERS_IN_PASSWORD = 1;
        private static final int UPPERCASE_LETTERS_IN_PASSWORD = 1;
        private static final int MINIMUM_CHARACTERS_IN_PASSWORD = 6;
    
        
        //factory, document, element
        private DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
        private DocumentBuilder builder;
        private Document doc;
        private Node userNode;
        private Node countryNode;
        private static String firstName, lastName, address, city, country, email, password;
        private Element user;
        private Element firstName1, lastName1, address1, city1, country1, email1, password1;
        
        
        public void doPost(HttpServletRequest rq, HttpServletResponse rs) throws IOException{
            // requesting the data from the server
            firstName = rq.getParameter("firstName");
            lastName = rq.getParameter("lastName");
            address = rq.getParameter("address");
            city = rq.getParameter("city");
            country = rq.getParameter("country");
            email = rq.getParameter("email");
            password = rq.getParameter("password");
        
            try {
                createNewUser();
            } catch (SAXException | IOException e) {
                e.printStackTrace();
            }
        
        
        }
        
        
        private boolean createNewUser() throws SAXException, IOException {
            
            Element element = null;
            doc = builder.parse(new File("userData.xml"));  
            
            // receiving the nodeLists to compare values, as to see whether we can create the user(email), 
            // and if yes, where(country)?
            
            NodeList countryList  = doc.getElementsByTagName("country");
            NodeList emailList = doc.getElementsByTagName("email");
            Element emailEl = checkEmail(emailList, countryNode, element);
            Node countryNode = checkCountry(countryList, userNode, element);
            
             if(emailEl == null && countryNode != null) {
                 this.firstName1 = doc.createElement("firstName");
                 this.lastName1 = doc.createElement("lastName");
                 this.address1 = doc.createElement("address");
                 this.city1 = doc.createElement("city");
                 this.country1 = doc.createElement("country");
                 this.email1 = doc.createElement("email");
                 this.password1 = doc.createElement("password");
                 
                 user = doc.createElement("user");
                 countryNode.appendChild(user);
                 user.appendChild(firstName1);
                 user.appendChild(lastName1);
                 user.appendChild(address1);
                 user.appendChild(city1);
                 user.appendChild(country1);
                 user.appendChild(email1);
                 user.appendChild(password1);
             }
             
            return false;
        
        }
            
        private Element checkEmail(NodeList emailList, Node node, Element element) {
            //looping through NodeList to compare emails
            String nodeValue;
            for(int i = 0 ; i < emailList.getLength(); i++) {
                node = emailList.item(i);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    element = (Element)node;
                    nodeValue = element.getNodeValue();
                    if(nodeValue.equals(email)) {
                        return null;
                    }
                }
            }
            return element;
        } 
        
        private Node checkCountry(NodeList countryList, Node node, Element element) {
            
            for(int i = 0 ; i < countryList.getLength(); i++) {
                node = countryList.item(i);
                if(node.getNodeType() == Node.ELEMENT_NODE) {
                    if(node.getNodeValue().equals(country)) {
                        return node;
                    }
                }
            }
            return null;
            
        }
    }

    java.lang.NullPointerException
        at com.andrija.crud.Register.createNewUser(Register.java:68)
        at com.andrija.crud.Register.doPost(Register.java:56)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:694)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:356)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:867)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1760)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:834)

This is the html code I’m working with:

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h1>Sign up</h1>
        <form action="Register" method="POST">
            <label for="firstName">First Name:</label><input type="text" name="firstName" id="firstName">
            <label for="lastName">Last Name:</label><input type="text" name="lastName" id="lastName">
            <label for="address">Address:</label><input type="text" name="address" id="address">
            <label for="city">City:</label><input type="text" name="city" id="city">
            <label for="country">Country:</label><select name="country" id="country">
                <option value="US">United States</option>
                <option value="Canada">Canada</option>
                <option value="UK">United Kingdom</option>
                <option value="France">France</option>
                <option value="Germany">Germany</option>
                <option value="China">China</option>
                <option value="Japan">Japan</option>
            </select>
            <label for="email">Email:</label><input type="text" name="email" id="email">
            <label for="password">Password:</label><input type="text" name="password" id="password">
            <input type="submit">
        </form>

</body>
</html>

createAsyncThunk not executing

I have such slice:

import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";

export const fetchNews = createAsyncThunk("blog/fetchNews", async () => {
  try {
    const { data } = await axios.get(
      "https://*my url*"
    );
    return data;
  } catch (error) {
    console.log("Error");
  }
});

export const blogSlice = createSlice({
  name: "blog",
  initialState: {
    news: [],
    status: null,
    error: null,
  },
  reducers: {
    setItems(state, action) {
      state.news = action.payload;
    },
  },
  extraReducers: {
    [fetchNews.pending]: (state) => {
      state.status = "loading";
      state.status = null;
    },
    [fetchNews.fulfilled]: (state, action) => {
      state.status = "success";
      state.news = action.payload;
    },
    [fetchNews.rejected]: (state, action) => {},
  },
});

export const { setMedia } = blogSlice.actions;

export default blogSlice.reducer;

and such store:

import { configureStore } from "@reduxjs/toolkit";
import blog from "./slices/blogSlice";

export const store = configureStore({
  reducer: {
    blog,
  },
});

async function is not called, looking at the trycatch, the function doesn’t run at all. I can’t figure out what could be wrong. I changed the link to mocapi before posting.

Vuejs3: Cannot read properties of null (reading ‘title’)

I am learning vuejs language and I would like to create a tabs component and I followed a tutorial that allowed me to create a simple one and now I would like to customize it. For example I would like to not necessarily have to put the title of the table. I tried to put a default value to the title property but when I map the slots table I get an error because it does not find the title.
In TabsComponent we have:

 <template>
  <div class="tabs">
    <ul class="tabs_header">
      <li
        v-for="title in tabTitles"
        :key="title"
        @click="actualTitle = title"
        :class="{ actual: title === actualTitle }"
      >
        {{ title }}
      </li>
    </ul>
    <slot></slot>
  </div>
</template>

<script>
import { ref, provide } from "vue";
export default {
  name: "TabsComponents",
  setup(props, { slots }) {
    const tabTitles = ref(slots.default().map((tab) => tab.props.title));   
    const actualTitle = ref(tabTitles.value[0]);

    provide("actualTitle", actualTitle);
    return { actualTitle, tabTitles };
  },
};
</script>

<style scoped>
.tabs {
  max-width: 400px;
  margin: 0 auto;
}

.tabs_header {
  margin-bottom: 10px;
  list-style: none;
  padding: 0;
  display: flex;
}

.tabs_header li {
  width: 80px;
  text-align: center;
  padding: 10px 20px;
  margin-right: 10px;
  background-color: #ddd;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.4s all ease-out;
}

.tabs_header li.actual {
  background-color: darkorange;
  color: black;
}
</style>

And in TabComponent we have:

<template>
  <div class="tab-content" v-show="title == actualTitle" :title="title">
    <slot></slot>
  </div>
</template>

<script>
import { inject } from "vue";

export default {
  name: "TabComponent",
  props: {
    title: {
      type: String,
      default: "Tab",
    },
  },
  setup() {
    const actualTitle = inject("actualTitle");
    return {
      actualTitle,
    };
  },
};
</script>

<style scoped>
.tab-content {
  min-height: 400px;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 3px 5px 5px rgba(0, 0, 0, 0.05);
}
</style>

This is the App.vue :

<template>
  <TabsComponent>
    <TabComponent> I'm first Tab </TabComponent>
    <TabComponent title="Second"> I'm second Tab </TabComponent>
    <TabComponent title="Disabled"> I'm disabled Tab </TabComponent>
  </TabsComponent>
</template>

<script>
import TabsComponent from "./components/TabsComponent.vue";
import TabComponent from "./components/TabComponent.vue";
export default {
  name: "App",
  components: {
    TabComponent,
    TabsComponent,
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin-top: 60px;
}
</style> 

My error is here when I do <TabComponent> I'm first Tab </TabComponent> I have an error on this line const tabTitles = ref(slots.default().map((tab) => tab.props.title)); in TabsComponents file. And I don’t understand because I thought the default value in TabComponent file would be taken.

Update 2 Solidity contract variables with one transaction

How do I chain two contract updates together?

This following code works for individually updating each of them, but I have to approve the first update in Metamask, then wait for it to finish before the other update asks to be confirmed in Metamask :

      await vaultcontract.methods.update7Day([update7day]).send({from: account}).then(function(receipt){
        document.getElementById("7dayupdated").innerText = "updated";
      });
     
      await vaultcontract.methods.update30Day([update30day]).send({from: account}).then(function(receipt){
        document.getElementById("30dayupdated").innerText = "updated";
      });

How can I do both with one transaction?

at node:internal/main/run_main_module:17:47 { code: ‘MODULE_NOT_FOUND’, requireStack: [] }

node:internal/modules/cjs/loader:936

throw err;
^

Error: Cannot find module ‘C:UserskpkboDesktopweb development for internshipchat-appserverindex.js’
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint
[as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []
}

[nodemon] app crashed – waiting for file changes before starting…

Yesterday it was running properly but today when i started its not working i tried installing all node modules again but still not working

converting JS to PY

i was trying to do brute force in my problem, and since im new i ask my brother to help he give me this code, and i have no idea how to use Js,can anyone help me converting this JS code to Python?

const solution = jobs => {
  let maxWeight = 0;

  for (let i = 0; i < jobs.length; i++) {
    const endTime = jobs[i][1];
    const weight = jobs[i][2];

    const filteredJobs = jobs.filter(
      (job, index) => job[0] >= endTime);

    const returnedWeight = solution(filteredJobs);
  if (returnedWeight + weight > maxWeight) {
    maxWeight = returnedWeight + weight;
  }
  }
  return maxWeight;
};

const arr = [[1, 2, 50], [3, 5, 20], [6, 19, 100], [2, 100, 200]]
console.log(solution(arr))

sorry for my bad englsh

How can I turn an async into a promise?

I want to turn all async functions into promises because promises are the latest feature in javascript. Am I thinking about this correctly, is aync analogous to promises?

exports.genre_detail = function(req, res, next) {

    async.parallel({
        genre: function(callback) {
            Genre.findById(req.params.id)
                .exec(callback);
        },

        genre_books: function(callback) {
            Book.find({ 'genre': req.params.id })
                .exec(callback);
        },

    }, function(err, results) {
        if (err) { return next(err); }
        if (results.genre == null) { // No results.
            var err = new Error('Genre not found');
            err.status = 404;
            return next(err);
        }
        // Successful, so render
        res.render('genre_detail', { title: 'Genre Detail', genre: results.genre, genre_books: results.genre_books });
    });

};