get
Method added to the configured Map type. Retrieves an instance of the Map type via the connection.
Map.get(params)
Parameters
- params
{Object}
:identifying parameters of the instance to retrieve
Returns
{Promise<Map>}
:
Promise
returning the Map instance being retrieved
Usage
// import connection plugins
var canMap = require("can-connect/can/map/map");
var constructor = require("can-connect/constructor/constructor");
var dataUrl = require("can-connect/data/url/url");
// define connection type
var Todo = DefineMap.extend({
id: "number",
complete: "boolean",
name: "string"
});
// create connection
connect([canMap, constructor, dataUrl],{
Map: Todo,
url: "/todos"
})
// retrieve instance
Todo.get({id: 5}).then(function(todo){
...
});