골란의 노출/api/목록 인터페이스로 작성된 백엔드가 있습니다. GET에서 호출 될 때 목록을 반환하고 매개 변수가 포함 된 POST를 수신하면 새 목록을 만듭니다. 표준 코어 아약스 요소로 읽을 수 있습니다. 엄청난 양의 예제가 있습니다.폴리머 REST 백엔드
POST를 통해 새 요소를 만들고 싶을 때 무엇을해야하는지 이해하지 못했습니다. 설명서를 읽고 반나절 동안 샘플 코드를 검색했는데 올바른 방향으로 나를 가리킬 수 있습니까? // 도움 주셔서 감사합니다. 실제로 보내시는 json의 잘못된 형식이었습니다. 개념적 관점에서 뭔가를 오해했다는 것을 말하면서 아직도 내 마음 속에 어두운 구름이 있습니다. 이것은 :
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/core-ajax/core-ajax.html">
<polymer-element name="channels-service" attributes="channels">
<template>
<style>
:host {
display: none;
}
</style>
<core-ajax id="ch_load"
auto
url="/api/list"
on-core-response="{{channelsLoaded}}"
handleAs="json">
</core-ajax>
<core-ajax id="ch_update"
url="/api/list"
on-core-response="{{channelsUpdated}}"
method="POST"
handleAs="json">
</core-ajax>
</template>
<script>
Polymer('channels-service', {
created: function() {
this.channels = [];
},
channelsLoaded: function() {
// Make a copy of the loaded data
this.channels = this.$.ch_load.response.slice(0);
},
newChannel: function(ch_name) {
// this.$.ch_update.body = "ch_name";
this.$.ch_update.body = '{"Name":"pitchalist2"}'
this.$.ch_update.go();
},
channelsUpdated: function() {
//window.log(this.$.ch_update.response.slice(0));
}
});
</script>
</polymer-element>
올바르게 기록 된 데이터 레이어입니까? 그것은 나에게 매우 직관적이지 않으며, 로컬 데이터 저장소를 사용하는 예제에서 보면 더 쉽게 작동합니다.
core-ajax를 core-rest로 감싸는 무언가가 있다면 각 엔드 포인트 * 각 메소드에 대해 하나의 요소를 작성할 필요가 없다는 것이 궁금합니다. – iJames