Sourav
Sourav

Reputation: 504

How to send a JSON request with params in middle of URL

I have been trying to create a node.js json request object. And i need to pass a parameter in middle of url path. I am giving the below however it is not working.. COuld you please help ?

var alertModel = {
                method:'GET',
                pathparam:{accountNum: '21703774771466'},
                path:"/v1/note/sen/${accountNum}/notes",
                qs:{

                    category:'NOTES'
                }
            }

Upvotes: 1

Views: 389

Answers (2)

str
str

Reputation: 45019

You are using template literals with double quotes. Instead use backticks:

path: `/v1/note/sen/${accountNum}/notes`,

Upvotes: 1

remi lebret
remi lebret

Reputation: 1

Use backquote:

let accountNum=21703774771466;
var alertModel = {
    method:'GET',
    path:`/v1/note/sen/${accountNum}/notes`,
    qs:{

        category:'NOTES'
    }
}

work with node.js >= 4.x.x

Upvotes: 0

Related Questions