2016-10-19 1 views
0

데이터를 모의하기 위해 Ember-cli-mirage를 사용하고 있습니다. 내 로컬 컴퓨터에있는 프로덕션 API의 부분을 천천히 http://localhost:8000에 통합하려고합니다. Ember docs tell me 나는 각 모델마다 다른 호스트를 가질 수 있도록 어댑터를 설정할 수 있어야합니다.Ember 모델 호스트 어댑터가 신기루를 초과하지 않습니다.

나는 customer 모델을 가지고 있으며 성공적으로 데이터를 제공하는 설정 ember-cli-mirage를 가지고 있습니다. 고객 모델은 localhost : 8000으로 분리하려는 첫 번째 모델입니다.

import DS from 'ember-data'; 

export default DS.RESTAdapter.extend({ 
    host: 'http://localhost:8000', 
    namespace: 'api/v1' 
}); 

을하지만 내가 오류 받고 있어요 호출 할 때 :

나는 다음과 같이 설정 어댑터/customer.js을했습니다

Mirage: Error: Your Ember app tried to GET 'http://localhost:8000/api/v1/customers', 
     but there was no route defined to handle this request. 
     Define a route that matches this path in your 
     mirage/config.js file. Did you forget to add your namespace? 

그리고 내 헤더 관리자를 보여줍니다 고객이 신기루 서버에 요청하는 중입니다.

Request URL:http://localhost:6543/customers 
Request Method:GET 
Status Code:304 Not Modified 
Remote Address:[::1]:6543 

내 사기와 관련이 있다고 생각합니다. 그림/환경 .js 설정 그래서 나는 잠재적 인 해결 방법으로 https://github.com/samselikoff/ember-cli-mirage/issues/497#issuecomment-183458721의 변형을 찾고 있어요. 하지만 왜 신기루가 어댑터를 무시할 수 없는지 나는 알 수 없습니다.

답변

0

이 문서에 대한 신기루 문서를 다시 읽어야합니다.

// app/adapters/application.js 
import DS from 'ember-data'; 

export default DS.RESTAdapter.extend({ 
    host: 'http://localhost:8000', 
    namespace: 'api/v1' 
}); 

이 어떤 식 으로든 주시기에 도움이 경우 내가 추가

// mirage/config.js 
import Mirage from 'ember-cli-mirage'; 

export default function() { 

    this.urlPrefix = 'http://localhost:8000'; 
    this.namespace = '/api/v1'; 

    // Requests for customers 
    this.get('/customers'); 
    this.get('/customers/:id'); 
    this.post('/customers'); 
    this.del('/customers/:id'); 
    this.patch('/customers/:id'); 

    // Passthrough to Django API 
    this.passthrough('/customers'); 

} 

내 응용 프로그램 어댑터에서이 작업을하려면 : 엠버 우회 신기루를 통해 특정 요청을 전달하는 신기루 수있는 passthrough function이있다 이 대답을 upvote 줄 :