{"id":23339813,"url":"https://github.com/xiyusullos/axios-rest","last_synced_at":"2025-04-07T14:39:58.598Z","repository":{"id":57098257,"uuid":"467562968","full_name":"xiyusullos/axios-rest","owner":"xiyusullos","description":"Axios-REST: A RESTful client based on axios","archived":false,"fork":false,"pushed_at":"2023-07-19T15:19:05.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-20T11:47:05.868Z","etag":null,"topics":["axios","client","rest","restful-client"],"latest_commit_sha":null,"homepage":"","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/xiyusullos.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-08T15:12:52.000Z","updated_at":"2024-01-19T06:48:59.000Z","dependencies_parsed_at":"2024-12-21T04:15:24.312Z","dependency_job_id":"5dd76577-496b-43fd-832d-9e515f8fe942","html_url":"https://github.com/xiyusullos/axios-rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiyusullos%2Faxios-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiyusullos%2Faxios-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiyusullos%2Faxios-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiyusullos%2Faxios-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiyusullos","download_url":"https://codeload.github.com/xiyusullos/axios-rest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247672989,"owners_count":20977045,"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":["axios","client","rest","restful-client"],"created_at":"2024-12-21T04:15:20.897Z","updated_at":"2025-04-07T14:39:58.558Z","avatar_url":"https://github.com/xiyusullos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Axios-REST: A RESTful client based on axios\n\nThis library intends to provide an elegant RESTful client.\n\n## Installation\n\n```shell\nnpm i @aponder.top/axios-rest\n```\n\n## Usage example\n\n```javascript\nimport axiosRest from '@aponder.top/axios-rest'\n\nconst handleOk = (r) =\u003e console.info(r)\nconst handleError = (e) =\u003e console.debug(e.toString())\n\nlet baseUrl = 'https://httpbin.org'\nconst axiosRequestConfig = {}\nlet Rest\n// create Rest with axios interceptors and debug\nRest = axiosRest(baseUrl, axiosRequestConfig, false, true)\nRest.axiosInstance.interceptors.response.use(handleOk, handleError)\n// Here, create Rest without interceptors and debug normally\n// Rest = axiosRest(baseUrl)\n\n// use a common name to be the alias of the resource variable name\nlet _\n\n// define the resource with a '/'\nlet Users = Rest('/users')\n\nconst newUser = { username: 'root', password: 'root' }\n\n_ = Users\nconsole.info(`\\nTest: ${_.resourcePath}`)\n_.create(newUser).response//.then(handleOk).catch(handleError)\n_.list({ page: 1, page_size: 10 }).response\n_.detail(1).response\n_.update(10, newUser).response\n_.partial_update(11, newUser).response\n_.delete(12).response\n\n_.login = _.make_plural_action('login')\n_.login(newUser).response\n\n_.disable = _.make_single_action('disable')\n_.disable(13).response\n\n_.log = _.make_single_action('log', 'GET')\n_.log(14).response\n\n// define the response without a '/'\nlet Blogs = Rest('blogs')\n_ = Blogs\nconsole.info(`\\nTest: ${_.resourcePath}`)\n_.create(newUser).response//.then(handleOk).catch(handleError)\n_.list({ page: 1, page_size: 10 }).response\n_.detail(1).response\n_.update(10, newUser).response\n_.partial_update(11, newUser).response\n_.delete(12).response\n\n// combine two resources, the parameter of `of` is an instance of Resource\nlet User10Blogs = Users.detail(10).of(Blogs)\n_ = User10Blogs\nconsole.info(`\\nTest: ${_.resourcePath}`)\n_.create(newUser).response//.then(handleOk).catch(handleError)\n_.list({ page: 1, page_size: 10 }).response\n_.detail(1).response\n_.update(10, newUser).response\n_.partial_update(11, newUser).response\n_.delete(12).response\n\n// combine two resources, the parameter of `of` is an instance of Resource\nlet User10Articles = Users.detail(10).of('articles')\n_ = User10Articles\nconsole.info(`\\nTest: ${_.resourcePath}`)\n_.create(newUser).response//.then(handleOk).catch(handleError)\n_.list({ page: 1, page_size: 10 }).response\n_.detail(1).response\n_.update(10, newUser).response\n_.partial_update(11, newUser).response\n_.delete(12).response\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiyusullos%2Faxios-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiyusullos%2Faxios-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiyusullos%2Faxios-rest/lists"}