getData
A requestHandler that gets a single record from the store.
Store.getData(request, response)
A requestHandler
that gets a single record from the store.
import {QueryLogic, fixture, ajax} from "can";
import {Todo} from "//unpkg.com/can-demo-models@5";
const todoStore = fixture.store( [
{id: 1, name: "Do the dishes"},
{id: 2, name: "Walk the dog"}
], new QueryLogic(Todo) );
fixture( "GET /todos/{id}", (req, res) => {
todoStore.getData(req, res);
} );
ajax( {url: "/todos/1", type: "GET"} ).then( value => {
console.log( value ); //-> {id:1, name:"Do the dishes"}
});
Parameters
- request
{object}
:An HTTP Request object
- response
{object}
:An HTTP response object.