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

Sends three requests at once #50

Open
Sasha-Andrukhov opened this issue Dec 1, 2021 · 1 comment
Open

Sends three requests at once #50

Sasha-Andrukhov opened this issue Dec 1, 2021 · 1 comment

Comments

@Sasha-Andrukhov
Copy link

No description provided.

@Sasha-Andrukhov
Copy link
Author

Future<http.Response> request(String method, String url,
{dynamic body, dynamic headers}) async {
Map<String, String> headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Auth0-Client': this.encodedTelemetry()
};
if (bearer != null) {
headers['Authorization'] = this.bearer;
}
Map<String, Future<http.Response>> handler = {
'POST': http.post(Uri.parse(url), body: Map.from((body ?? {}))),
'GET': http.get(Uri.parse(url), headers: headers),
'PATCH': http.patch(Uri.parse(url), body: Map.from((body ?? {}))),
};
http.Response uriResponse;
try {
uriResponse = await handler[method];
} catch (e) {
print(e);
}
return uriResponse;
}

uriResponse = await handler[method];
Sends three requests and returns the result of the desired
Снимок экрана 2021-12-01 в 13 30 59

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

No branches or pull requests

1 participant