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

125
Views
Promise on Reactnative

I write a promise to insert data in sqlite:

var promise_insertData=new Promise(function(resolve, reject){
          db.transaction((tx) =>{
                tx.executeSql('INSERT INTO chontact (recordID,user, phone) VALUES (?,?,?)',[recordID, name, number],
                (tx, results) => {
                    var status=(results.rowsAffected > 0) ? true : false;
                    if(status)
                        resolve()
                    else
                        reject()
                    }
                );
              });
                        reject()
})

when I try to insert data I got error

promise_insertData(db,recordid,name,phone).then(function(result){
                Toast.show('ok...');
                del_item();
            }).catch(function(error){
                Toast.show('error');
              })

Error:

TypeError: (0, _$$_REQUIRE(_dependencyMap[12], "./JSfiles/functions").promise_insertData) is not a function. (In '(0, _$$_REQUIRE(_dependencyMap[12], "./JSfiles/functions").promise_insertData)(db, recordid, textinput, textinputphone)', '(0, _$$_REQUIRE(_dependencyMap[12], "./JSfiles/functions").promise_insertData)' is an instance of Promise)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Give this a try. You should be able to promise_insertData(stuff).then(doSomethingElse) I'm not sure about the final reject() in your code, that might be wrong.

const promise_insertData = (db, recordid, name, phone) => {
  return new Promise(function(resolve, reject){
    db.transaction((tx) =>{
      tx.executeSql('INSERT INTO chontact (recordID,user,phone) VALUES (?,?,?)',[recordid, name, phone],
      (tx, results) => {
          var status=(results.rowsAffected > 0) ? true : false;
          if(status)
              resolve()
          else
              reject()
      });
    });
    reject() // ??
  })
};

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!