updateData
A requestHandler that updates a record in the store.
Store.updateData(request, response)
A requestHandler
that updates an item in the store.
import {QueryLogic, fixture, ajax} from "can";
import {Todo} from "https://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( "/todos/{id}", todoStore);
fixture( "PUT /todos/{id}", (req, res) => {
todoStore.updateData(req, res);
} );
const ajaxSettings = {
url: "/todos/1",
type: "PUT",
data: {name: "test"},
};
ajax(ajaxSettings).then( () => {
ajax( {url: "/todos/1", type: "GET"} ).then( value => {
console.log(value); //-> {name:"test", id:1}
});
});
Parameters
- request
{object}
:An HTTP Request object
- response
{object}
:An HTTP response object.