JavaScript github.com

urlcat – a tiny JS library for building URLs  ↦

If building URLs to make API requests is something you do commonly in your JavaScript code, this little dependency might be worthy of a position in your package.json. It’ll help you turn code like this:

const requestUrl = `${API_URL}/users/${id}/blogs/${blogId}/posts?limit=${limit}&offset=${offset}`;

Into code like this, which is more ergonomic and less error prone:

const requestUrl = urlcat(API_URL, '/users/:id/posts', { id, limit, offset });
urlcat – a tiny JS library for building URLs

Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00