Hello, I'm Stanko, a software engineer in Belgrade, writing mostly about JavaScript and React.

Uploading files using 'fetch' and 'FormData'


Today I learned:

To upload files using fetch and FormData is supported in IE10+. you must not set Content-Type header.

const fileInput = document.querySelector('#your-file-input') ;
const formData = new FormData();

formData.append('file', fileInput.files[0]);

const options = {
  method: 'POST',
  body: formData,
  // If you add this, upload won't work
  // headers: {
  //   'Content-Type': 'multipart/form-data',
  // }

fetch('your-upload-url', options);
Read more

CSS only elastic hover effect

Some CSS fun. Lately I’ve stumbled upon couple of websites with elastic hover effect on buttons. Each one was using SVG morphing, which is fine, but I was wondering how hard would it be to implement it in CSS.

It ended up up being pretty easy.

Read more

JavaScript animation loop

I’ve been really busy lately, doing both work and pet projects. At the moment I’m playing with three.js trying to clone old DOS game to JavaScript. Games (and animations in general) need animation loop in which we are going to update the scene and re-render it.

Example animations are simplified and they just move a box 60px per second. But the concepts applied are universal and can be used for more complicated real life cases.

Read more

JavaScript 'time ago' function


Snippet for a rather popular requirement. Formatting a date in a nice way, using infamous “time ago” function. This is the basic version which I adapt to fit a specific project. To keep it easily customizable to your needs, I haven’t packaged it up.

Just pass a date to it, and function will return one of the seven possible formats:

Read more

First talk in React series

This time we joined forces with our friends from IT Girls. They are promoting tech among women, and helping them start a career in it. Together, we are organizing a series of meetups and workshops about React.

Last night, my colleague Nemanja and myself had a pleasure to give the first talk in the series. We are planning to have one more meetup followed by a couple of workshops, and for a great finale, hackathon will be organized.

After yesterday’s introduction to React, we’ll continue with more in depth talks, including more code examples. To reserve your place, make sure you apply in time, by following IT Girls’ website and Facebook.

Due to large interest, we might repeat the first talk. Slides are available for download.