Skip to content

Instantly share code, notes, and snippets.

@Dyndrilliac

Dyndrilliac/data_init.js

Last active Apr 26, 2017
Embed
What would you like to do?
COP-4813-Final-Project
const BASE_URL = "proxy/api/v2/"
const URLS = {
ENDPOINTS: BASE_URL,
DAYSOFWEEK: BASE_URL + "daysofweek/",
EQUIPMENT: BASE_URL + "equipment/",
EXERCISE: BASE_URL + "exercise/",
EXERCISEINFO: BASE_URL + "exerciseinfo/",
EXERCISECATEGORY: BASE_URL + "exercisecategory/",
EXERCISECOMMENT: BASE_URL + "exercisecomment/",
EXERCISEIMAGE: BASE_URL + "exerciseimage/",
INGREDIENT: BASE_URL + "ingredient/",
INGREDIENTWEIGHTUNIT: BASE_URL + "ingredientweightunit/",
LANGUAGE: BASE_URL + "language/",
LICENSE: BASE_URL + "license/",
MUSCLE: BASE_URL + "muscle/",
WEIGHTUNIT: BASE_URL + "weightunit/",
SETTING_REPETITIONUNIT: BASE_URL + "setting-repetitionunit/",
SETTING_WEIGHTUNIT: BASE_URL + "setting-weightunit/",
};
function getData(request) {
var retVal = null;
$.ajax({
url: request + "?format=json",
dataType: "json",
success: (data) => {
retVal = data;
}
});
return retVal;
}
var endpoints;
var daysofweek;
var equipment;
var exercise;
var exerciseinfo;
var exercisecategory;
var exercisecomment;
var exerciseimage;
var ingredient;
var ingredientweightunit;
var language;
var license;
var muscle;
var weightunit;
var setting_repetitionunit;
var setting_weightunit;
$(document).ready((e) => {
endpoints = getData(URLS.ENDPOINTS);
daysofweek = getData(URLS.DAYSOFWEEK);
equipment = getData(URLS.EQUIPMENT);
exercise = getData(URLS.EXERCISE);
exerciseinfo = getData(URLS.EXERCISEINFO);
exercisecategory = getData(URLS.EXERCISECATEGORY);
exercisecomment = getData(URLS.EXERCISECOMMENT);
exerciseimage = getData(URLS.EXERCISEIMAGE);
ingredient = getData(URLS.INGREDIENT);
ingredientweightunit = getData(URLS.INGREDIENTWEIGHTUNIT);
language = getData(URLS.LANGUAGE);
license = getData(URLS.LICENSE);
muscle = getData(URLS.MUSCLE);
weightunit = getData(URLS.WEIGHTUNIT);
setting_repetitionunit = getData(URLS.SETTING_REPETITIONUNIT);
setting_weightunit = getData(URLS.SETTING_WEIGHTUNIT);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment