diff --git a/js/JokeService.js b/js/JokeService.js index 4cf136e..7b0c197 100644 --- a/js/JokeService.js +++ b/js/JokeService.js @@ -1,20 +1,20 @@ class JokeService { - constructor(category = ['programming', 'coding', 'development'], lang = 'en') { - this.category = Array.isArray(category) ? category : [category]; + constructor(categories = ['programming', 'coding', 'development'], lang = 'en') { + this.categories = Array.isArray(categories) ? categories : [categories]; this.lang = lang; this.apiBaseUrl = 'https://v2.jokeapi.dev/joke/' } setCategory(category) { - this.category = Array.isArray(category) ? category : [category]; + this.categories = Array.isArray(category) ? category : [category]; } tell() { let service = this; axios.get( - service.apiBaseUrl + getRandomItem(service.category) + '?lang=' + service.lang + service.apiBaseUrl + service.categories.join(',') + '?lang=' + service.lang ).then((response) => { if (response.data.error === false) { service.show(response.data); @@ -43,10 +43,6 @@ function showNotification(text) { body: text }); } else { - // alert(text); + console.warn('Notifications sind nicht erlaubt.') } } - -function getRandomItem(items) { - return items[Math.floor(Math.random()*items.length)]; -} \ No newline at end of file