DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
      • behaviors
        • ./base/
        • ./cache-requests/
        • ./can/map/
        • ./can/ref/
        • ./constructor/callbacks-once/
        • ./constructor/
        • ./constructor/store/
        • ./data/callbacks/
        • ./data/callbacks-cache/
        • ./data/combine-requests/
        • ./data/localstorage-cache/
        • ./data/memory-cache/
        • ./data/parse/
        • ./data/url/
          • options
            • ajax
            • url
          • data methods
            • createData
            • destroyData
            • getData
            • getListData
            • updateData
        • ./data/worker/
        • ./fall-through-cache/
        • ./real-time/
      • modules
        • ./can/base-map/
        • ./can/model/
        • ./can/super-map/
        • ./can/tag/
        • ./helpers/weak-reference-map
      • data types
        • DataInterface
        • Instance
        • InstanceInterface
        • List
        • ListData
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-connect
  • /
  • ./data/url/
  • /
  • url
  • / On this page
    • url

      property

      Specify the url and methods that should be used for the "Data Methods".

      String

      If a string is provided, it's assumed to be a RESTful interface. For example, if the following is provided:

      url: "/services/todos"
      

      ... the following methods and requests are used:

      • getListData - GET /services/todos
      • getData - GET /services/todos/{id}
      • createData - POST /services/todos
      • updateData - PUT /services/todos/{id}
      • destroyData - DELETE /services/todos/{id}

      Object

      If an object is provided, it can customize each method and URL directly like:

      url: {
        getListData: "GET /services/todos",
        getData: "GET /services/todo/{id}",
        createData: "POST /services/todo",
        updateData: "PUT /services/todo/{id}",
        destroyData: "DELETE /services/todo/{id}"
      }
      

      You can provide a resource property that works like providing url as a string, but overwrite other values like:

      url: {
        resource: "/services/todo",
        getListData: "GET /services/todos"
      }
      

      Finally, you can provide your own method to totally control how the request is made:

      url: {
        resource: "/services/todo",
        getListData: "GET /services/todos",
        getData: function(param){
          return new Promise(function(resolve, reject){
            $.get("/services/todo", {identifier: param.id}).then(resolve, reject);
          });
        }
      }
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.