diff --git a/backend/components/alexa.js b/backend/components/alexa.js index b06c44f..2fc124d 100644 --- a/backend/components/alexa.js +++ b/backend/components/alexa.js @@ -33,7 +33,7 @@ module.exports = { updateIntentsJSON: function () { databaseHelper - .loadSkill (config.SKILL_DB_ID) + .getSkill (config.SKILL_DB_ID) .then (skill => { skill.intents.map (intent => { alexaApp.intent ( diff --git a/backend/helpers/database.js b/backend/helpers/database.js index bd662a2..b5f3abd 100644 --- a/backend/helpers/database.js +++ b/backend/helpers/database.js @@ -52,7 +52,7 @@ module.exports = { }); }, - loadSkill: function (skillDbID) { + getSkill: function (skillDbID) { return new Promise ((resolve, reject) => { db .collection ('skill_list') @@ -92,20 +92,5 @@ module.exports = { } }); }); - }, - - getSkill: function (id) { - return new Promise ((resolve, reject) => { - db - .collection ('skill_list') - .find ({_id: ObjectID (id)}) - .toArray ((err, result) => { - if (err) { - reject (err); - }else{ - resolve (result); - } - }); - }); - }, + } }; diff --git a/web/src/App.js b/web/src/App.js index b3bd1fe..663d0ec 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -31,11 +31,10 @@ class App extends Component { }; getSkill(this.state._id).then(l=>l.json()).then(result=>{ - let jResult = result[0]; - if (jResult===undefined) return; - this.setState({ skillID:jResult.skillID,skillName:jResult.skillName, invocationName: jResult.invocationName, - invocationAnswer: jResult.invocationAnswer, - allIntents: jResult.intents, contactEmail: jResult.contactEmail}) + if (result===undefined) return; + this.setState({ skillID:result.skillID,skillName:result.skillName, invocationName: result.invocationName, + invocationAnswer: result.invocationAnswer, + allIntents: result.intents, contactEmail: result.contactEmail}) }) this.handleIntentClick = this.handleIntentClick.bind(this);