【发布时间】:2018-03-30 22:19:04
【问题描述】:
我在 Stackoverflow 上查看了这个问题,但仍然无法弄清楚如何摆脱这个错误。基本上,我正在尝试使用 Wordpress API 并将其连接到我的 Ember 应用程序,方法是按照本教程 https://www.codesandnotes.com/ember-js/ember-wordpress/
我收到此错误:
我无法弄清楚它为什么会出现或如何摆脱它。我想不出任何地方/其他人可以问,所以任何帮助都会非常感激。 这是我的代码:
app/router.JS
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.route('about');
this.route('members');
});
export default Router;
app/routes/member.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('member');
}
});
app/models/member.js
import DS from 'ember-data';
import PostModel from 'ember-wordpress/models/post';
export default PostModel.extend({
});
app/config/environment.js
/* eslint-env node */
'use strict';
module.exports = function(environment) {
let ENV = {
modulePrefix: 'doe-site',
environment,
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
},
wordpressHost: 'http://wordpress.daughtersofeve.org/'
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
app/package.json
{
"name": "doe-site",
"version": "0.0.0",
"private": true,
"description": "Small description for doe-site goes here",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~2.15.1",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.3.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.0.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "~2.15.0",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.15.0",
"ember-welcome-page": "^3.0.0",
"ember-wordpress": "^0.1.7",
"loader.js": "^4.2.3"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
}
}
【问题讨论】:
-
该错误听起来像是您遇到的问题是您收到的有效负载未正确转换为 Ember Data 预期的内容。您可以发布您的服务器通过网络发回的内容吗?
标签: javascript ember.js wordpress-rest-api