{"id":15636519,"url":"https://github.com/slorber/ajax-interceptor","last_synced_at":"2025-06-22T11:04:09.383Z","repository":{"id":20945356,"uuid":"24233791","full_name":"slorber/ajax-interceptor","owner":"slorber","description":"This permits to wire interceptors on XHR requests and responses","archived":false,"fork":false,"pushed_at":"2018-12-14T19:03:56.000Z","size":5,"stargazers_count":121,"open_issues_count":1,"forks_count":22,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-22T11:01:50.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sebastienlorber.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slorber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-19T14:56:24.000Z","updated_at":"2024-11-21T10:26:06.000Z","dependencies_parsed_at":"2022-07-16T15:00:53.905Z","dependency_job_id":null,"html_url":"https://github.com/slorber/ajax-interceptor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/slorber/ajax-interceptor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slorber%2Fajax-interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slorber%2Fajax-interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slorber%2Fajax-interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slorber%2Fajax-interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slorber","download_url":"https://codeload.github.com/slorber/ajax-interceptor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slorber%2Fajax-interceptor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261282248,"owners_count":23134936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T11:04:39.216Z","updated_at":"2025-06-22T11:04:04.360Z","avatar_url":"https://github.com/slorber.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ajax-interceptor\n================\n\nThis permits to wire some request and response hooks on any Ajax calls.\n\nI find this handy, for exemple, to handle user session expiration and redirect the user to the login page whenever an Ajax call fails with an auth failure.\n\nInstall\n==============\n\nInstall it!\n```\nnpm install ajax-interceptor --save\n```\n\nUse it! (with **Browserify**)\n```javascript\nvar AjaxInterceptor = require(\"ajax-interceptor\");\n```\n\nNo other support for now, but feel free to contribute.\n\n\nAPI\n===============\n\n```javascript\n// Setup some callbacks\nAjaxInterceptor.addRequestCallback(function(xhr) {\n    console.debug(\"request\",xhr);\n});\nAjaxInterceptor.addResponseCallback(function(xhr) {\n    console.debug(\"response\",xhr);\n});\n\n// Will proxify XHR to fire the above callbacks\nAjaxInterceptor.wire();\n\n// Do some requests\n// ................\n\n// Will restore XHR and not fire anymore the callbacks\nAjaxInterceptor.unwire();\n```\n\nYou can add and remove callbacks dynamically while the interceptor is wired.\n\n\n\nAlternatives\n===================\n\nIf you just want to be able to intercept JQuery $.ajax() calls, [Global Ajax Event Handlers](http://api.jquery.com/category/ajax/global-ajax-event-handlers/) also work.\n\nLicense\n===================\n\nMIT\n\n# Hire a freelance expert\n\nLooking for a React/ReactNative freelance expert with more than 5 years production experience?\nContact me from my [website](https://sebastienlorber.com/) or with [Twitter](https://twitter.com/sebastienlorber).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslorber%2Fajax-interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslorber%2Fajax-interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslorber%2Fajax-interceptor/lists"}