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

219
Views
create promise without constructor nor resolve reject keywords

is it possible to create a promise without using the constructor new promise() nor using =>resolve & =>rejected ? check following method

export function getItById(id) {
  return fetch(`path`, {
    method: 'GET',
  }).then(rslt => {
    if (!rslt || !rslt.ok) {
      throw new Error('failure !');
    } else {
      return rslt.json();
    }
  });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm probably missing something, but it looks like everything is correct. The getItById function returns a promise. There is no need to create a promise.

So when using the function simply do

getItById(2).then(results => {
  console.log(results)
})

To answer the question "is it possible to create a promise without using new promise" the answer is yes, every http call and every database call, or a file read or write returns a promise.

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!