Async/ await, RNGeocoder.geocodePosition was called with 1 arguments but expects 3 arguments

I am trying to use a nested async/ await to get location details. However, I get the following error:

RNGeocoder.geocodePosition was called with 1 arguments but expects 3 arguments. If you haven’t changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.

Can anyone help?

  const getRescueMeLocationDetails = async (location) => {

    Geocoder.geocodePosition({
      lat: location.latitude,
      lng: location.longitude,
    })
      .then((res) => {
        return res;
      })
      .catch((err) => console.log(err));
  };

  const locateMe = async () => {
    const isGranted = await getLocationPermissions();
    setPermissionGranted(!!isGranted);
    if (isGranted) {
      Geolocation.getCurrentPosition(async (info) => {
        const lat = info.coords.latitude;
        const long = info.coords.longitude;
        const initialRegion = {
          latitude: lat,
          longitude: long,
        };
        const results = await getRescueMeLocationDetails(initialRegion);

        setLocation({ ...initialRegion, results });
      });
    }
  }; 

Estou tentando utilizar o comando ‘yarn create react-app myapp’, porém ele dá o seguinte erro que está no corpo dessa pergunta. Como proceder? [closed]

      - create-react-app
'C:UsersÍCARO' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
error Command failed.

O nome do meu usuário é ÍCARO TELES. Eu até consigo criar um projeto react usando ‘npx create-react-app myapp’ e depois utilizar yarn start pra começar a rodar. Porém não consigo iniciliar por yarn, pois dizem q é mais rápido a execução e deveria funcionar. Alguém sabe o que pode estar ocorrendo?

JavaScript: How to parse and then render a collection of dictionary entries? (arrays, key-value, sorting problem)

I want to display a list of dictionary entries in a table using javascript, using some combination of arrays and key/value pairs.

Here is what I’ve got to work so far:

let d = new Map();

d.set('stack', '[n] 1. an orderly pile 2. a list in which the next item to be removed is the most recently stored [v] 1. to arrange in order 2. to arrange in stacks')
d.set('overflow', '[n] 1. a large flow 2. the occurrence of surplus liquid')
;

document.write("<table>");

for (const [key, value] of d.entries()) {
document.write("<tr><td class="word">"+key+": "+"</td>" + "<td class="def">"+value+"</td>n");
}

document.write("</table>");
table {
    border: solid thin; 
    border-collapse: collapse;
}
td, th {
    border-collapse: collapse;
    border: 1.5px solid #aaa;
    padding: 4px 6px;
}
td.word {
    background-color: #cee5ec;
    vertical-align: top;
    border-right-width: 0px;
}
td.def {
    background-color: #eee;
    border-left-width: 0px;
}

Which looks okay, but it would be better (easier to type a large number of entries, and language-agnostic) if I could prepare all entries as a string literal and have the script parse and reorganize it:

let d = new Map();

let ddata = (`
stack: [n] 1. an orderly pile 2. a list in which the next item to be removed is the most recently stored [v] 1. to arrange in order 2. to arrange in stacks

overflow: [n] 1. a large flow 2. the occurrence of surplus liquid
`).split('n');

for (let i = 0; i < ddata.length; i++) {
    ddata[i].split(': ');
    d.set(ddata[i][0]), d.set(ddata[i][1]);
}

document.write("<table>");

for (const [key, value] of d.entries()) {
document.write("<tr><td class="word">"+key+": "+"</td>" + "<td class="def">"+value+"</td>n");
}

document.write("</table>");
table {
    border: solid thin; 
    border-collapse: collapse;
}
td, th {
    border-collapse: collapse;
    border: 1px solid #aaa;
    padding: 4px 6px;
}
td.word {
    background-color: #cee5ec;
    vertical-align: top;
    border-right-width: 0px;
}
td.def {
    background-color: #eee;
    border-left-width: 0px;
}

Performance in the browser is not really a concern at this point, as the end result will not be for a general audience. If performance does ever become a concern, I will serve the dictionary in sections.

The bigger issue right now is that the following code is not working as expected at all. Instead of splitting the string at the :, it’s making arrays of individual letters:

ddata[i].split(': ');
    d.set(ddata[i][0]), d.set(ddata[i][1]);

Ideally, I would like to create breakpoints at the part-of-speech symbol (noun, verb, etc). I know this can be done with regex like ([w*]) to match [n] or [noun]. And then each numbered meaning after than could be separated using d. to match 1. 2. and so on.

But putting it all together is turning into a long process of trial and error. Any help is appreciated.

Best way to change fileList in Javascript

Im making an web app for my ojt and they require me to add a delete function to a file field. Like if I choose to upload 3 of them there would be a preview to those file and I can remove some of them.

Can I just edit the fileField?
Example document.getElementbyID(“field”).files returns a filefield
Can I change that?

if not what is the best way to do it.

How can I redirect a user to a certain page in my Next.js _app.tsx in a useEffect. Currently in infinite redirect loop

I am using Next.js and Firebase.

I want to allow users to sign up with Google, but I need to check at the app level whether the users status is "incomplete" or "active".

Here is my useEffect. I listen to userData here and if the status is "incomplete", I redirect the user to the place where I can finish their sign up process (e.g. ask for username).

useEffect(() => {
    if (currentUser && currentUser !== "unauthenticated") {
      const docRef = doc(db, "users", currentUser.uid);
      return onSnapshot(docRef, async (doc) => {
        let data = doc.data() as UserData;
        if (!data) {
          return;
        }
        if (data?.status === "incomplete") {
          router.push("/complete-user-data");
          return;
        }
        setData(doc.data() as UserData);
      });
    }
  }, [currentUser, router, setData]);

This would work however as the useEffect is constantly rerendering due to the router.push("/complete-user-data");, I am in a infinite loop.

Whats the best way of creating a top level listener that will basically block the user based on a certain condition and push them to a certain route?

Is there a way to only push to a route if the user isn’t currently on that route (in my case, if they’re not on /complete-user-data?)

Next.js website shows sometimes “Index of” directory

I’m using npm run build and start server, Website works fine 3-5 days then the website shows “index of” and need to stop server and build the website again to get rid of “index of” directory.

What can cause this issue?

I have check if the server goes down under this period but have been live for 4 months now, prob just website goes down.

The html is not shown based on locally saved variables

I have a component that needs to display html based on a boolean variable. I make this variable the same as the one I set in the localStorage.
So if I click on foo, I set it to false both as a variable and in the localStorage. If I click on the bar I set it to true.
Now, before loading the component I’m going to get this variable, and I make it the same as the one I have locally, so if I clicked on foo, when I reload the component, the variable is false, and therefore the html should show me foo. but I don’t understand why he shows me bars!!!
It’s a bit complicated to explain I hope you understand from the code:

 <template>
   <div id="app">
     <h2 v-if="!isTrue">FOO</h2>
     <h2 v-else>BAR</h2>

    <button @click="foo()">FOO</button>
    <button @click="bar()">BAR</button>
   </div>
 </template>

 <script>
 export default {
   name: 'App',
   data: function () {
     return {
       isTrue: null,
     };
   },
   created() {
     const boh = localStorage.getItem('boh');
     this.isTrue = boh;
     console.log('boh', boh);
     console.log('isTrue', this.isTrue);
   },
   methods: {
     foo() {
       this.isTrue = false;
       localStorage.setItem('boh', false);
     },
     bar() {
       this.isTrue = true;
       localStorage.setItem('boh', true);
     },
   },
 };
 </script>

I am attaching an example on stackblitz so maybe you can do tests:
https://stackblitz.com/edit/vue-b3ieft?file=src%2FApp.vue

session.isvalid() is always valid amazon incognito

The problem is that even after expiration time that is 5 min for ID token and access token, the session is still validated for some reason I cannot understand. Can someone help me what should I Do?

let cognitoUser = userPool.getCurrentUser();
if (cognitoUser != null) {
  await cognitoUser.getSession((err, session) => {
   if (err) {
    console.error(err.message);
    return;
  }
  console.log('session validity: ' + session.isValid());

I tried waiting for 5 min or more to check if token has expired or not but it still says that it is valid whereas I was expecting it will go to refresh token function.

Retrieve records of objects with the correct types

I have the following Typescript function that query a table in Postgresql;I pass a generic type and I expect to have an array of objects of the same type passed as input, but it doesn’t:

export async function pgQuery<T>(
  query: string,
  postgreSqlClient: Client = postgreSqlClientGlobal
) {
  const log = extendLogger(_log, pgQuery);
  try {
    const res = await postgreSqlClient.query<T>(query);
    return res;
  } catch (error) {
    log.error({ error }, `PostgreSql query ERROR`);
    throw new Error(`PostgreSql query ERROR - ${error}`);
  }
}

The input type T is:

{country: string,
 age_min: number,
 age_max: number}

And in the table of the Postgresql DB I have records like this:

{
  loc_name: "Albania",
  age_min: 15,
  age_max: 64
}

but I have, as output of the executed query, object like this:

{country: string,
 age_min: string,
 age_max: string}

Example:

{
  loc_name: "Albania",
  age_min: "15",
  age_max: "64"
}

How to retrieve the correct types?

how to simplify pop, push and unshift?

i got data like this

const data = [
    {
        name: "Joe",
        age: 23,
        job: "Artist",
        hoby: "Drawing",
    },
    {
        name: "Michael",
        age: 21,
        job: "Engineer",
        hoby: "Fishing",
    },
    {
        name: "Jenifer",
        age: 22,
        job: "Dentist",
        hoby: "Gardening",
    },
]

and wanna got output like :

{ header: [ 'number', 'name', 'age', 'job', 'hoby' ],
   data:
   [ { name: 'Joe', age: 23, job: 'Artist', hoby: 'Drawing' },
      { name: 'Michael', age: 21, job: 'Engineer', hoby: 'Fishing' },
      { name: 'Jenifer', age: 22, job: 'Dentist', hoby: 'Gardening' } 
   ] }

requirement: use pop, push, shift and unshift

my code for now is :

data.unshift(header);
data.pop(data)
data.pop(data)
data.pop(data)
data.push(data1);

but i got wrong answer wkwkw

How to enable toggling between 3 menu items in shiny dashboard sidebar

I would like to make menu items in my shiny dashboard collapsible.

I found the post with similar question that had been answered some time ago:

solution to the problem with 2 div-s

However, the solution works only with 2 div-s. Is it possible to do similar thing with 3 menu items?

Attached reproducible code (posted by Martin Schmelzer)

library(shiny)
library(shinydashboard)

server <- function(input, output) { }
jsc <- '
$(document).ready(function () {
  $(".sidebar-menu").children("li").on("click", function() {
    $("#mult, #single").toggle();
  });
});
'

ui <- dashboardPage(
  dashboardHeader(title = "Dashboard", titleWidth = 290),  
  dashboardSidebar(
    width = 290,
    sidebarMenu(
      menuItem(
        "Multiple Incident Analysis",
        tabName = "dashboard",
        icon = icon("th")),      
      div(id = "mult", splitLayout(cellWidths = c("44%", "31%", "25%"),
                  dateInput("datefrom", "Date From:", format = "mm/dd/yyyy", Sys.Date()-5),
                  textInput("datefrom_hour", "Hour",
                            value = "12:00"),
                  textInput("datefrom_noon","AM/PM", value = "AM")),      
      splitLayout(cellWidths = c("44%", "31%", "25%"),
                  dateInput("dateto", "Date To:", format = "mm/dd/yyyy"),
                  textInput("dateto_hour", "Hour",
                            value = "11:59"),
                  textInput("dateto_noon","AM/PM", value = "PM"))),
      menuItem("Single Analysis", 
               tabName = "widgets", 
               icon = icon("th")),
      div(id = "single", style="display: none;", numericInput("tckt", "Ticket Number : ", 12345,  width = 290)),
      submitButton("Submit", width = "290")
    )),  
  dashboardBody(
    tags$head(tags$script(jsc))
  ))

shinyApp(ui, server)

“MODULE_NOT_FOUND” after npm run server

I just picked up a new book, Fullstack React and when trying to run the example app, I am getting the error of module not found. The modules in question are apparently live-server. Here’s the error message. I’ve done npm install before npm run server and no luck

> live-server public --host=localhost --port=3000 --middleware=./disable-browser-cache.js

internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module './disable-browser-cache.js'
Require stack:
- C:UsersSuleymanAppDataRoamingnpmnode_moduleslive-serverindex.js
- C:UsersSuleymanAppDataRoamingnpmnode_moduleslive-serverlive-server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at C:UsersSuleymanAppDataRoamingnpmnode_moduleslive-serverindex.js:189:10
    at Array.map (<anonymous>)
    at Object.LiveServer.start (C:UsersSuleymanAppDataRoamingnpmnode_moduleslive-serverindex.js:183:13)
    at Object.<anonymous> (C:UsersSuleymanAppDataRoamingnpmnode_moduleslive-serverlive-server.js:174:12)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\Users\Suleyman\AppData\Roaming\npm\node_modules\live-server\index.js',
    'C:\Users\Suleyman\AppData\Roaming\npm\node_modules\live-server\live-server.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] server: `live-server public --host=localhost --port=3000 --middleware=./disable-browser-cache.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersSuleymanAppDataRoamingnpm-cache_logs2022-03-29T07_43_25_808Z-debug.log
PS C:UsersSuleymanDownloadsfullstack-react-masterfullstack-react-mastervoting_app> ```