最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Mirage `passthrough` is not working - Stack Overflow

programmeradmin1浏览0评论

I'm trying to use passthrough for a POST request in this Ember project

this.passthrough('/thirdeye/entity?entityType=ANOMALY_FUNCTION');

This is what the call looks like in app/mirage/config.js. I got the following error:

Mirage: Your Ember app tried to POST '/thirdeye/entity?entityType=ANOMALY_FUNCTION',
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?

Clearly, I've added that call to the config file, but it's not being picked up. I read that passthrough only works for >= jquery 2.x, which my project is.

Does anyone know what else could cause this?

I'm trying to use passthrough for a POST request in this Ember project

this.passthrough('/thirdeye/entity?entityType=ANOMALY_FUNCTION');

This is what the call looks like in app/mirage/config.js. I got the following error:

Mirage: Your Ember app tried to POST '/thirdeye/entity?entityType=ANOMALY_FUNCTION',
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?

Clearly, I've added that call to the config file, but it's not being picked up. I read that passthrough only works for >= jquery 2.x, which my project is.

Does anyone know what else could cause this?

Share Improve this question asked Oct 30, 2017 at 22:46 johnwjjohnwj 4491 gold badge8 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I found out the problem was I had to do this.passthrough('/thirdeye/***'); since the call has query params. It works now.

I couldn't get passthrough working at all, the examples I saw for external URLs were just being ignored and the responses on Github were a bit vague. In the end I was able to use the function override for it to whitelist patterns matches:

this.passthrough(request =>
  [
    /amazon/
  ].some((regex) => regex.test(request.url)));

i.e. anything with amazon in the URL is ignored.

Note, include at the end of the routes function.

发布评论

评论列表(0)

  1. 暂无评论