🧑💻 add environment variable for url in frontend
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
c5e45424ea
commit
f08bd430f3
7 changed files with 18 additions and 6 deletions
2
frontend/.env.example
Normal file
2
frontend/.env.example
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# URL variable
|
||||||
|
VITE_URL="http://localhost:8080"
|
|
@ -1,3 +1,5 @@
|
||||||
|
const URL = import.meta.env.VITE_URL;
|
||||||
|
|
||||||
interface Question {
|
interface Question {
|
||||||
QuestionID: number;
|
QuestionID: number;
|
||||||
QuestionText: string;
|
QuestionText: string;
|
||||||
|
@ -22,7 +24,7 @@ interface QAData {
|
||||||
export const getUserQuestions = async (
|
export const getUserQuestions = async (
|
||||||
respondentID: number
|
respondentID: number
|
||||||
): Promise<QAData> => {
|
): Promise<QAData> => {
|
||||||
let url = `https://helseundersokelsen.online/userquestions?respondentID=${respondentID}`;
|
let url = `${URL}/userquestions?respondentID=${respondentID}`;
|
||||||
|
|
||||||
const response = fetch(url, {
|
const response = fetch(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
const URL = import.meta.env.VITE_URL;
|
||||||
|
|
||||||
export const postBugData = async (bugText: string) => {
|
export const postBugData = async (bugText: string) => {
|
||||||
let url = "https://helseundersokelsen.online/submitbug";
|
let url = `${URL}/submitbug`;
|
||||||
|
|
||||||
const response = fetch(url, {
|
const response = fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
const URL = import.meta.env.VITE_URL;
|
||||||
|
|
||||||
export const postEvaluationData = async (evaluationText: string) => {
|
export const postEvaluationData = async (evaluationText: string) => {
|
||||||
let url = "https://helseundersokelsen.online/submiteval";
|
let url = `${URL}/submiteval`;
|
||||||
|
|
||||||
const response = fetch(url, {
|
const response = fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
const URL = import.meta.env.VITE_URL;
|
||||||
|
|
||||||
export const postFormData = async (
|
export const postFormData = async (
|
||||||
respondentID: number,
|
respondentID: number,
|
||||||
allFormAnswers: string
|
allFormAnswers: string
|
||||||
) => {
|
) => {
|
||||||
let url = "https://helseundersokelsen.online/submitanswers";
|
let url = `${URL}/submitanswers`;
|
||||||
|
|
||||||
const response = fetch(url, {
|
const response = fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const URL = import.meta.env.VITE_URL;
|
||||||
|
|
||||||
interface postUserformDataReponse {
|
interface postUserformDataReponse {
|
||||||
respondentID: number;
|
respondentID: number;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +14,7 @@ export const postUserformData = async (
|
||||||
county: string,
|
county: string,
|
||||||
submit_date: string
|
submit_date: string
|
||||||
): Promise<postUserformDataReponse> => {
|
): Promise<postUserformDataReponse> => {
|
||||||
let url = "https://helseundersokelsen.online/submituserform";
|
let url = `${URL}/submituserform`;
|
||||||
let personnel = healthcare_personnel == "Ja" ? true : false;
|
let personnel = healthcare_personnel == "Ja" ? true : false;
|
||||||
let licensed = is_licensed == "Ja" ? true : false;
|
let licensed = is_licensed == "Ja" ? true : false;
|
||||||
let answered_before = has_answered_before == "Ja" ? true : false;
|
let answered_before = has_answered_before == "Ja" ? true : false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import adapter from "@sveltejs/adapter-vercel";
|
import adapter from "@sveltejs/adapter-auto";
|
||||||
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Config} */
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
|
|
Reference in a new issue