Search code examples
angulartypescriptxmlhttprequest

Defining and using xhook in an Angular App


How to use xhook to interpret ingress and egress http request in an Angular Hybrid App. Following is the xhook definition and usage.

declare var xhook: any;

xhook.before((request, callback) => {
});

xhook.after((request, response, callback) => {
});

xhook dependency is added and installed through package.json file

"dependencies": {
  ...
  "xhook": "^1.4.9"
  ...
}

However ReferenceError: xhook is not defined error is thrown when the code gets executed.

Other way to include xhook too gave different error, say adding in index.html file.

Any other way to include the package successfully available?


Solution

  • You can just import it like this:

    import xhook from 'xhook';