Node JS web service based on api key


I have some web services, written in node js and express. I want to use api key based service.
Suppose I currently have a web service "getRooms".

app.get('/getRooms/', function (req, res) {
    'use strict';
    N.API.getRooms(function (rooms) {
    },function (err) {

I am using it by calling https://xxxxxx/getRooms.
Now I want to use https://xxxxxx/APIKEY/getRooms. This APIKEY is different for different clients. So how do I modify my web services to achieve this?


You can modify it as /APIKEY/getrooms to achieve the desired result. However it would be better it you send APIKEY in request header but obviously it depends on your case.

Answered By – Sohaib Farooqi

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published