My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Versioning REST API - what's the best practices for client JS / is there a client-lib with versioning support?

Pavel Svitek's photo
Pavel Svitek
·Mar 10, 2017

We are standing in front of implementing versioning to our REST API (in URL versioning schema).

/api/v1.2/users (implements /list)
/api/v2.0/users (might implement new endpoint /filter)
/api/v2.1/users

I'm looking for solution where I would be able to write code like this:

const client = apiClient(apiUrl, version=1.2)
client.list()
client.filter(...) # undefined

const client = apiClient(apiUrl, version=2.0)
client.list()
client.filter(...) # defined