From f6dc1508dd04a4bd36dfe150c578d5a523dfacba Mon Sep 17 00:00:00 2001 From: vincent Date: Mon, 30 Mar 2020 21:27:06 +0200 Subject: [PATCH] configure api --- client/config/dev.env.js | 2 -- client/config/index.js | 4 +-- client/config/prod.env.js | 4 +-- client/src/api/index.js | 32 ++++++++++++------- client/src/components/Teammood.vue | 51 ++++++++++++++++++++++++++---- 5 files changed, 69 insertions(+), 24 deletions(-) diff --git a/client/config/dev.env.js b/client/config/dev.env.js index e857645..55a82ff 100644 --- a/client/config/dev.env.js +++ b/client/config/dev.env.js @@ -4,6 +4,4 @@ const prodEnv = require('./prod.env') module.exports = merge(prodEnv, { NODE_ENV: '"development"', - ROOT_API:'"http://localhost:5000"', - }) diff --git a/client/config/index.js b/client/config/index.js index beddc48..16e17eb 100644 --- a/client/config/index.js +++ b/client/config/index.js @@ -9,7 +9,7 @@ module.exports = { // Paths assetsSubDirectory: 'static', - assetsPublicPath: '/', + assetsPublicPath: '', // Various Dev Server settings host: 'localhost', // can be overwritten by process.env.HOST @@ -44,7 +44,7 @@ module.exports = { build: { // Template for index.html - index: path.resolve(__dirname, '../../backend/dist/index.html'), + index: path.resolve(__dirname, '../dist/index.html'), // Paths assetsRoot: path.resolve(__dirname, '../dist'), diff --git a/client/config/prod.env.js b/client/config/prod.env.js index 48dee35..d7e5d5e 100644 --- a/client/config/prod.env.js +++ b/client/config/prod.env.js @@ -1,5 +1,5 @@ 'use strict' module.exports = { NODE_ENV: '"production"', - ROOT_API:'"/"' -} + ROOT_API:'"https://outlook.office.com/webhook/d607186d-098c-4d35-b188-440315e30b33@1d593042-a69d-49e0-8d1c-0daf8ac1717b/IncomingWebhook/b84597cf0ff2443a997d3bea0aad92bb/84d01e58-379e-4aff-862f-d308fc799011"' +} \ No newline at end of file diff --git a/client/src/api/index.js b/client/src/api/index.js index db4281f..4681c2e 100644 --- a/client/src/api/index.js +++ b/client/src/api/index.js @@ -1,17 +1,25 @@ import axios from 'axios'; -const API_PATH = `${process.env.ROOT_API}/api/v1`; -export function fetchchaine(num) { - return axios.get(`${API_PATH}/chaine/${num}`); -} -export function fetchemission(num) { - return axios.get(`${API_PATH}/chaine/${num}/emission`); -} -export function putparsechaine(jwt) { - return axios.put(`${API_PATH}/chaine/`, '', { headers: { Authorization: `Bearer: ${jwt}` } }); -} -export function authenticate(userData) { - return axios.post(`${API_PATH}/login/`, userData); +const API_PATH = `${process.env.ROOT_API}`; + +export async function PostMood(MoodData) { + const response = await fetch(API_PATH, { + method: 'POST', // *GET, POST, PUT, DELETE, etc. + mode: 'no-cors', // no-cors, *cors, same-origin + cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached + headers: { + 'Content-Type': 'application/json' + // 'Content-Type': 'application/x-www-form-urlencoded', + }, + redirect: 'follow', // manual, *follow, error + referrerPolicy: 'no-referrer', // no-referrer, *client + body: JSON.stringify(MoodData) // body data type must match "Content-Type" header + }); + return await response + + +// return axios.post(`${API_PATH}`, JSON.stringify(MoodData)); + } // export function register(userData) { // return axios.post(`${API_URL}/register/`, userData); diff --git a/client/src/components/Teammood.vue b/client/src/components/Teammood.vue index 5a75a4d..d980c76 100644 --- a/client/src/components/Teammood.vue +++ b/client/src/components/Teammood.vue @@ -11,16 +11,16 @@
- +
- +
- +
@@ -29,7 +29,7 @@
- +
@@ -46,11 +46,13 @@