DEV Community


Posted on

Don't bother me with your awesome framework, I simply want to retrieve data from a public API :-)

One credo, do simple things the simplest way possible...

You can test it here VanillaJS

Beware, don't copy and paste code on production, without asking yourself if it is safe or not.

For example, you have noticed, that my code does not allow any input from user.
If it was the case I would adopt another strategy...

Thanks Heiker :-)

let cible = document.getElementById("app");

let ligneUser = (info) => `
    <td><img src=${info.picture.thumbnail}></img></td>

let footer = `
  <div>Vanilla JS only...</div>

let tableau = (lignes) => `
  <table border="1">
    <tr class="footer">
      <td colspan="2">${footer}</td>

function displayUsers(data) {
  const users ="");
  cible.innerHTML = `

async function getListUsers(numusers) {
  cible.innerHTML = "searching...";
  let resp = await fetch(`${numusers}`);
  let users = await resp.json();

Enter fullscreen mode Exit fullscreen mode

Top comments (3)

vonheikemen profile image
Heiker • Edited

But just ask yourself, is this safe?

artydev profile image
artydev • Edited

Hy Heiker,

It was a joke :-), look at my previous posts.

But, for sure, for simple things like this one, for a personnal use, why bother ?
And it is safe as long as you don't request input from user, or you don't send sensitive informations.

I am very concerned by simplicity, and that is why my framework of choice is Mithril coupled with the Meiosis pattern.

Betwise, I am found of functional programming :-)


vonheikemen profile image

I'm glad this is not a serious post.

I still think it would be a good idea to place a explicit warning. Because you never know who might want to copypaste your code.