Ember.js EmberJS Mirage 404获取/租赁错误
在下一个教程页面之前,我将一直关注本页的教程()。(实际上,我一直在学习,直到完成教程。) 一切似乎都很顺利。✔Ember.js EmberJS Mirage 404获取/租赁错误,ember.js,http-status-code-404,ember-cli-mirage,Ember.js,Http Status Code 404,Ember Cli Mirage,在下一个教程页面之前,我将一直关注本页的教程()。(实际上,我一直在学习,直到完成教程。) 一切似乎都很顺利。✔ 余烬服务器正在服务并正确显示在浏览器中。✔ Ember开发构建也可以正确显示。✔ 但是余烬生产构建给我/rentals 404错误。✖ 如何修复生产构建中的404错误 这是我的幻影/config.js export default function() { // These comments are here to help you get started. Feel free
余烬服务器正在服务并正确显示在浏览器中。✔
Ember开发构建也可以正确显示。✔ 但是余烬生产构建给我/rentals 404错误。✖
如何修复生产构建中的404错误 这是我的幻影/config.js
export default function() {
// These comments are here to help you get started. Feel free to delete them.
/*
Config (with defaults).
Note: these only affect routes defined *after* them!
*/
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
// this.namespace = ''; // make this `api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
/*
Shorthand cheatsheet:
this.get('/posts');
this.post('/posts');
this.get('/posts/:id');
this.put('/posts/:id'); // or this.patch
this.del('/posts/:id');
http://www.ember-cli-mirage.com/docs/v0.2.x/shorthands/
*/
this.get('/rentals', function(db, request) {
let rentals = [{
type: 'rentals',
id: 1,
attributes: {
title: 'Grand Old Mansion',
owner: 'Veruca Salt',
city: 'San Francisco',
type: 'Estate',
bedrooms: 15,
image: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Crane_estate_(5).jpg'
}
}, {
type: 'rentals',
id: 2,
attributes: {
title: 'Urban Living',
owner: 'Mike Teavee',
city: 'Seattle',
type: 'Condo',
bedrooms: 1,
image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg'
}
}, {
type: 'rentals',
id: 3,
attributes: {
title: 'Downtown Charm',
owner: 'Violet Beauregarde',
city: 'Portland',
type: 'Apartment',
bedrooms: 3,
image: 'https://upload.wikimedia.org/wikipedia/commons/f/f7/Wheeldon_Apartment_Building_-_Portland_Oregon.jpg'
}
}];
if(request.queryParams.city !== undefined) {
let filteredRentals = rentals.filter(function(i) {
return i.attributes.city.toLowerCase().indexOf(request.queryParams.city.toLowerCase()) !== -1;
});
return { data: filteredRentals };
} else {
return { data: rentals };
}
});
}
url前缀和名称空间没有改变任何内容,仍然是/rentals 404错误
找不到GET 404“网络错误:找不到404-”
处理路由时出错:索引余烬数据请求GET/rentals返回404
生产版本中禁用了ember cli mirage,您应该在配置中显式启用它:
if (environment === 'production') {
ENV['ember-cli-mirage'] = {
enabled: true
};
}
生产版本中禁用了ember cli mirage,您应该在配置中明确启用它:
if (environment === 'production') {
ENV['ember-cli-mirage'] = {
enabled: true
};
}
文档已更新,包含此问题的修复程序 现在,如果您转到文档中名为的部分,您将看到它显示打开
/tests/acceptance/list rentals test.js
,并在顶部插入此导入语句:
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
然后在tests/acceptance/list rentals test.js中添加setupMirage(hooks)代码>紧接着设置应用程序测试(挂钩)
然后,数据和测试将通过。文档已更新,包含此问题的修复程序
现在,如果您转到文档中名为的部分,您将看到它显示打开/tests/acceptance/list rentals test.js
,并在顶部插入此导入语句:
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
然后在tests/acceptance/list rentals test.js中添加setupMirage(hooks)代码>紧接着设置应用程序测试(挂钩)
然后数据和测试就会通过。为什么我得到了-1
?为什么我得到了-1
?