2017-03-03 5 views
0

위한 방법) 방법을 정의백본은 다음과 같이 정의 내가 (가져 오기에 대한 사용자 정의 래퍼 메소드를 생성하려는 컬렉션을

let personCollection = Collection.extend({ 
    mainIndex: 'id', 
    url: 'https://jsonplaceholder.typicode.com/posts', 
    model:Person, 

    findAll:function(){ 
     return this.fetch({url:this.url, type: 'POST'}); 
    } 

}); findall은에() 메소드가 나는 URL 경로 및 HTTP 메소드, 하지만 위의 코드를 보내기를 변경하려는

GET 요청

답변

0

이이 코드를보고는 앰퍼샌드 문제가 될 수 있습니다 https://github.com/AmpersandJS/ampersand-sync/blob/master/core.js#L73

// If passed a data param, we add it to the URL or body depending on request type 
    if (options.data && type === 'GET') { 
     // make sure we've got a '?' 
     options.url += includes(options.url, '?') ? '&' : '?'; 
     options.url += qs.stringify(options.data); 
     //delete `data` so `xhr` doesn't use it as a body 
     delete options.data; 
    } 

여기서 변수는 methodMap에서 제공되며 옵션에서 재정의했을 수도 있습니다.

여전히 디버깅하지 않고는 확신 할 수 없습니다. 단계별 안내를 통해 xhrImplementation에 무엇이 전송되는지 확인해야합니다.