{"id":18544477,"url":"https://github.com/instructure/ic-ajax","last_synced_at":"2025-04-05T23:07:40.064Z","repository":{"id":12110989,"uuid":"14700444","full_name":"instructure/ic-ajax","owner":"instructure","description":"ember-friendly jQuery.ajax wrapper","archived":false,"fork":false,"pushed_at":"2015-06-24T16:40:38.000Z","size":588,"stargazers_count":166,"open_issues_count":14,"forks_count":28,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T21:09:13.519Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/instructure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2013-11-25T22:27:49.000Z","updated_at":"2025-01-23T23:52:59.000Z","dependencies_parsed_at":"2022-09-05T11:11:18.425Z","dependency_job_id":null,"html_url":"https://github.com/instructure/ic-ajax","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-ajax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-ajax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-ajax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-ajax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instructure","download_url":"https://codeload.github.com/instructure/ic-ajax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411234,"owners_count":20934653,"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-11-06T20:16:40.315Z","updated_at":"2025-04-05T23:07:40.045Z","avatar_url":"https://github.com/instructure.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ic-ajax\n=======\n\n[![Build Status](https://travis-ci.org/instructure/ic-ajax.png)](https://travis-ci.org/instructure/ic-ajax)\n\nEmber-friendly `jQuery.ajax` wrapper.\n\n- returns RSVP promises\n- makes apps more testable (resolves promises with `Ember.run`)\n- makes testing ajax simpler with fixture support\n\nInstallation\n------------\n\n`bower install ic-ajax`\n\n... or ...\n\n`npm install ic-ajax`\n\nModule Support\n--------------\n\nNote the `dist` directory has multiple module formats, use whatever\nworks best for you.\n\n- AMD\n\n  `define(['ic-ajax'], function(ajax) {});`\n\n- Node.JS (CJS)\n\n  `var ajax = require('ic-ajax')`\n\n- Globals\n\n  `var ajax = ic.ajax;`\n\n  All instructure canvas stuff lives on the `ic` global.\n\nAPI\n---\n\nThis lib simply wraps `jQuery.ajax` with two exceptions:\n\n- success and error callbacks are not supported\n- does not resolve three arguments like $.ajax (real promises only\n  resolve a single value). `request` only resolves the response data\n  from the request, while `raw` resolves an object with the three\n  \"arguments\" as keys if you need them.\n\nOther than that, use `request` exactly like `$.ajax`.\n\n```js\nvar ajax = ic.ajax;\n\nApp.ApplicationRoute = Ember.Route.extend({\n  model: function() {\n    return ajax.request('/foo');\n  }\n}\n\n// if you need access to the jqXHR or textStatus, use raw\najax.raw('/foo').then(function(result) {\n  // result.response\n  // result.textStatus\n  // result.jqXHR\n});\n```\n\nSimplified Testing\n------------------\n\nIn order to test newly added code you must rebuild the distribution.\n\n```bash\nbroccoli build dist\n```\n\nAdding fixtures with `defineFixture` tells ic-ajax to resolve the promise\nwith the fixture matching a url instead of making a request. This allows\nyou to test your app without creating fake servers with sinon, etc.\n\nExample:\n\n```js\nic.ajax.defineFixture('api/v1/courses', {\n  response: [{name: 'basket weaving'}],\n  jqXHR: {},\n  textStatus: 'success'\n});\n\nic.ajax.request('api/v1/courses').then(function(result) {\n  deepEqual(result, ic.ajax.lookupFixture('api/v1/courses').response);\n});\n```\n\nTo test failure paths, set the `textStatus` to anything but `success`.\n\n\nContributing\n------------\n\nInstall dependencies and run tests with the following:\n\n```sh\nnpm install\nnpm test\n```\n\nFor those of you with release privileges:\n\n```sh\nnpm run-script release\n```\n\nSpecial Thanks\n--------------\n\nInspired by [discourse ajax][1].\n\nLicense and Copyright\n---------------------\n\nMIT Style license\n\n(c) 2014 Instructure, Inc.\n\n\n  [1]:https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/mixins/ajax.js#L19\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fic-ajax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstructure%2Fic-ajax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fic-ajax/lists"}