Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support of queryParams on paramsHeaders and URL #109

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ClementRoyer
Copy link

New "feature"

Updating the value of your queryParameters can know affect your url and your header.

How to use

Juste had :{queryParametersName} to your path and/or your header !

Exemple

You are the owner of an API that manage different club.
You want to list every user of a club, nothing more simple :

"url": "http://my_beautiful_path/api/club/:club_id/",
[...]
"queryParams": [
    {
        "name": "club_id",
        "type": "select",
        "label": "Club",
        "optionSource": {
            "url": "http://my_beautiful_path/api/clubs/",
            "displayPath": "name",
            "dataPath": null,
            "valuePath": "id"
        },
        "required": true
    }
]

ClementRoyer and others added 4 commits April 4, 2020 17:42
# New "feature"

Updating the value of your queryParameters can know affect your url and your header.

## How to use

Juste had :{querryParametersName} to your path and/or your header !

## Exemple

You are the owner of an API that manage different club.\
You want to list every user of a club, nothing more simple :

```
"url": "http://my_beautiful_path/api/club/:club_id/",
[...]
"queryParams": [
    {
        "name": "club_id",
        "type": "select",
        "label": "Club",
        "optionSource": {
            "url": "http://my_beautiful_path/api/clubs/",
            "displayPath": "name",
            "dataPath": null,
            "valuePath": "id"
        },
        "required": true
    }
]
```
// TODO: Add docs to "urlReplaceOnly"
if (param.urlReplaceOnly) {
const urlParamName = `:${param.name}`;
outputUrl = outputUrl.replace(urlParamName, param.value as string);
} else {
params.push(`${param.name}=${param.value || ''}`);
if (url.includes(":"+param.name))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add curly brackets to if/else statements.

@@ -61,12 +61,22 @@ class HttpService {
continue;
}

//eslint-disable-next-line
Object.entries(headers).map(([key, value]) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's the current place to add this logic. buildUrl meant (as the name suggests), to build the request url.
To manipulate headers, please add another method,

// TODO: Add docs to "urlReplaceOnly"
if (param.urlReplaceOnly) {
const urlParamName = `:${param.name}`;
outputUrl = outputUrl.replace(urlParamName, param.value as string);
} else {
params.push(`${param.name}=${param.value || ''}`);
if (url.includes(":"+param.name))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use string concatenation.

// TODO: Add docs to "urlReplaceOnly"
if (param.urlReplaceOnly) {
const urlParamName = `:${param.name}`;
outputUrl = outputUrl.replace(urlParamName, param.value as string);
} else {
params.push(`${param.name}=${param.value || ''}`);
if (url.includes(":"+param.name))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use string concatenation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants