'reuse param and headers in requests
I have a class with a lot of methods, in these methods code usually starts with
response = requests.get(
url=f"{self.base_url}api/v1/integration/apps",
headers={"Authorization": f"Bearer {self.token}"},
verify=False,
params = {"id": project_id, "other_param": value}
)
how can I avoid duplicate url, headers in each method, which approach is better?
I'm thinking about Wrapper for requests, is it a good approach?
requests.request(
method=method,
url=url,
headers=headers,
verify=verify,
params=params,
json=json
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
