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/
          • parseInstanceData
          • parseListData
          • parseListProp
          • parseInstanceProp
        • ./data/url/
        • ./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/parse/
  • / On this page
    • can-connect/data/parse/parse

      module

      Extract response data into a format needed for other extensions.

      • source

      dataParse( baseConnection )

      Overwrites the DataInterface methods to run their results through either parseInstanceData or parseListData.

      Parameters

      1. baseConnection {Object}:

        The base connection.

      Use

      data/parse is used to modify the response data of "data interface" methods to comply with what is expected by "instance interface" methods. For example, if a service was returning list data at the /services/todos url like:

      {
        todos: [
          {todo: {id: 0, name: "dishes"}},
          {todo: {id: 2, name: "lawn"}}
        ]
      }
      

      That service does not return ListData in the right format which should look like:

      {
        data: [
          {id: 0, name: "dishes"},
          {id: 2, name: "lawn"}
        ]
      }
      

      To correct this, you can configure data-parse to use the parseListProp and parseInstanceProp as follows:

      connect([
        require("can-connect/data/parse/parse"),
        require("can-connect/data/url/url")
      ],{
       parseListProp: "todos",
       parseInstanceProp: "todo"
      })
      

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