using Typescript callback style error handling

async,tipjs,async-await,promise,callback

getData(someParameter, function(err: Error | null, resultA: ResultA) {
  if(err !== null) {
    // do something like calling the given callback function and pass the error
    getMoreData(resultA, function(err: Error | null, resultB: ResultB) {
      if(err !== null) {
        // do something like calling the given callback function and pass the error
        getMoreData(resultB, function(resultC: ResultC) {
          getMoreData(resultC, function(err: Error | null, d: ResultD) {
            if(err !== null) {
              // you get the idea?
            }
          })
        });
      }
    });
  }
});

Có thể bạn đã miss một số snippets code

Sử dụng Promise.all với fetch

Sử dụng Promise.all hiệu quả sẽ làm cho hiệu suất của code chúng ta tăng lên đáng kể. Và mã sau đây giúp các bạn có thể get được nhiều data mà không ảnh hưởng tới performance.

flatMap()

Use flatMap() creates a new array with sub-array elements flattened by specified depth.

Sự khác biệt giữa substr và substring

Sự khác biệt giữa substr() và substring() chức năng trong JS là gì?

kiểm tra email trong javascript

kiểm tra email trong javascript

Getting the last element of a split string array

Getting the last element of a split string array