Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
How to resolve the content of this promise?

So i have the following filter component

<SelectSearchFilter
            name="search"
            labelKey="option"
            width="small"
            valueKey="value"
            options={[
              { option: "Publication Name", value: "name", exact: true },
              { option: "Publication ID", value: "id", exact: true },
              { option: "Publisher ID", value: "publisher", exact: true },
              { option: "ISSN", value: "issn", exact: true },
              {
                option: "Legacy FH Pub Code",
                value: "id",
                exact: true,
                customValue: getLegafyFhPubCode(null)
              }
            ]}
          />

It works but sometimes I need to do some preprocessing of the values in the back and not get the value directly from the input field. So I have created an option called customValue, to pass functions as values.

First issue is that , ideally I want to call customValue as a reference to the function, I dont want it to execute yet, im forced to put null as argument, but really i dont want to execute it yet.

This leads me to the selecsearfilter component

Specifically to this input

  onKeyDown={async event => {
    if (event.key === "Enter") {
      console.log("----------------ENTER-----------------")
      const values = await getOptionValue(selectValue, valueKey)
      console.log(selectValue) //[option: 'Publication name', value: 'name', exact: true] | [option: 'Legacy FH Pub Code', value: 'id', exact: true, customValue: Promise]
      let customValue = await selectValue.customValue(inputValue)
      console.log(customValue)
      updateFilter(name, {
        property: getOptionValue(selectValue, valueKey),
        text: customValue ? customValue : inputValue
      });
    }
  }}

And in the code above, take attention to the comment Usually when there is no custom value, I simply set the inputValue in text when updating the filter and im done.

The problem happens now that, if customValue prop is available (which is the case), I want to set the response of that promise as inputValue instead. But it comes as Promise , and i get

Uncaught (in promise) TypeError: selectValue.customValue is not a function
    at onKeyDown (SelectSearchFilter.tsx:108:1)

How can I resolve that promise? And how can I pass that function to the component without having to specify any argument like null?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

the error is happening because your CustomValue is not a function as it says, but the result of the function getLegafyFhPubCode(null) you should pass the function without call in it getLegafyFhPubCode or you can use an arrow function () => getLegafyFhPubCode(null)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!