'How do catch error on React Native SQLite

I have the code:

let dirs = RNFetchBlob.fs.dirs
  RNFetchBlob
  .config({
    fileCache : false,
  })
  //pega o arquivo da internet
  .fetch('GET', 'https://URL_WITH_QUERY_TEXT')
  .then((res) => {
    //lê o arquivo salvo anteriormente
    db.transaction((tx) => {
        var sql = res
        tx.executeSql(sql, [], (tx, results) => {
            alert('OK!')
          })
          .catch((error) => alert(error));
      });
  })

I not receive none alert.

Can I catch the error correctly?



Solution 1:[1]

Please try using the following way after the response use comma(,) and console error callback.

dbConnection.transaction(function (tx) {
        tx.executeSql(query, values, async (tx1) => {
          dispatch(clearTodos());
          const data = await getTodosFromDbMethod(dbConnection, 1);
        }, (error) => {
        console.log("error: " + JSON.stringify(error))
        reject(error);
    });
  });

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gurjinder Singh