Interceptors issue

How to use interceptors in angular for backendless calls

Hello Rajasekhar

Why do you need that?, our JS-SDK is completely ready for work without any middleware.

Anyways, you can patch Backendless Request module in way something like this:

  const backendlessRequestDecorator = (function decorateBackendlessRequest() {
  const preMiddleware = []
  const postMiddleware = []

  const _nativeRequestSend = Backendless.Request.prototype.send

  Backendless.Request.prototype.send = function() {
    const request = this

    preMiddleware.forEach(middleware => middleware(request))

  return _nativeRequestSend.apply(request, arguments)
    .then(result => {
      preMiddleware.forEach(middleware => middleware(request, null, result))

    return result
  })
  .catch(error => {
    postMiddleware.forEach(middleware => middleware(request, error))

    throw error
      })
  }

 return {
    addPreMiddleware : middleware => preMiddleware.push(middleware),
    addPostMiddleware: middleware => postMiddleware.push(middleware),
  }

})()

backendlessRequestDecorator.addPreMiddleware(request => {
  console.log('request.path', this.path)
  console.log('request.queryParams', this.queryParams)
  console.log('request.headers', this.headers)
  ...
  request.set('my-custom-header', 'some-value')
})

backendlessRequestDecorator.addPostMiddleware((request, error, result) => {
  if (error) {
    console.log('error', error)
  } else {
    console.log('result', result)
  }
}) 

Regards, Vlad

can we check online/offline status or slow network detection using backendless?

I assume the question is not related to Backendless, you should search the solution somewhere on JS forums, for example: https://stackoverflow.com/

here is the first link what I found https://davidwalsh.name/detecting-online

Thank you for your response