Skip to content

Commit

Permalink
Read WebClip list
Browse files Browse the repository at this point in the history
[Issue] #1366
[Problem] No example to read webclip list
[Solution] Provide exemplary code using fetch API

Signed-off-by: Lukasz Slachciak <l.slachciak@samsung.com>
  • Loading branch information
lmslachciak committed Aug 21, 2020
1 parent 1dff9ad commit ef8df52
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/mobile/HomeApp/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
news: false,
nowontv: false
}
};
},
// TODO: remove below directive after webClipList use
// eslint-disable-next-line no-unused-vars
webClipList = [];

function getWidgetsState() {
var latestNews = document.querySelector("#latest-news-check"),
Expand Down Expand Up @@ -49,6 +52,16 @@
loadWeatherJS();
}

function loadWebClipList() {
const requestURL = "api/webcliplist";

fetch(requestURL)
.then((response) => response.json())
.then((data) => {
webClipList = data;
});
}

function onPopupSubmit() {
getWidgetsState();
toggleWidgetsState();
Expand Down Expand Up @@ -83,6 +96,7 @@
burgerButton.addEventListener("click", onButtonClick);
popupButton.addEventListener("click", onPopupSubmit);
loadWeatherJS();
loadWebClipList();
}

document.addEventListener("pagebeforeshow", init);
Expand Down

0 comments on commit ef8df52

Please sign in to comment.