diff --git a/.gitignore b/.gitignore index c2658d7..713d500 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +.env diff --git a/package.json b/package.json index 0d656b4..fc01004 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "license": "ISC", "dependencies": { "body-parser": "^1.16.0", + "dotenv": "^4.0.0", "express": "^4.14.0", "express-cors": "0.0.3", "nodemon": "^1.11.0", diff --git a/src/controller.js b/src/controller.js index b0d6538..00eec51 100644 --- a/src/controller.js +++ b/src/controller.js @@ -1,18 +1,19 @@ const request = require('request') -const API_KEY = require('./key') -const BASE_URL = `https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize` -const IMAGE_URL = 'localhost:300/image' +require('dotenv').load() +const API_KEY = process.env.EMOTION_API_KEY +const API_URL = `https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize` +const APP_BASE_URL = 'localhost:3000' function getEmotionAnalysis(req, res) { request({ - url: BASE_URL, + url: API_URL, method: 'POST', headers: { 'Content-Type': 'application/json', 'Ocp-Apim-Subscription-Key': API_KEY }, - body: JSON.stringify({url: IMAGE_URL}) + body: JSON.stringify({url: /*IMAGE URL GOES HERE SOMEHOW*/}) }, function (error, response, body) { if (!error && response.statusCode == 200) {