Home > simplified-fetch > urnParser
parse the template strings with params
Signature:
urnParser: (template: Array<string>, ...placeholder: Array<number | string>) => URNParser
function base on Template literals (Template strings) ES6 Template literals
you do can use the string type as placehloder, and give an object as params, match them with key string. But the way it used would look like: urnParser/${'key1'}/${'key2'}
, Api.someApi(body, {key1:’‘,key2:’’})
Anyway, need better idea.
// init|create
someApi:{
urn: urnParser`/xxx/${0}/${1}`
}
// somewhere
Api.someApi(body, ['user', [1,2,3]])
// getUrl: /xxx/user/1,2,3