nex_common_api

Last updated:

0 purchases

nex_common_api Image
nex_common_api Images
Add to Cart

Description:

nex common api

Getting started #
A Dart class for sending HTTP GET and POST requests, with optional token-based authentication and API key support.
Features #

Send HTTP GET and POST requests with optional headers.
Support for token-based authentication.
Option to include an API key in requests.

Installation #
Add this package to your pubspec.yaml file:
dependencies:
nex_common_api: <latest-version>
copied to clipboard
Run flutter pub get to install the dependencies.
Usage #
Importing the Class #
First, import the necessary packages:
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'path_to_api_methods/api_methods.dart';
copied to clipboard
Example #
Sending a GET Request
To send a basic GET request:
void main() async {
try {
var response = await ApiMethods().getMethod(url: "https://api.example.com/data");
print(response);
} catch (e) {
print("Error: $e");
}
}
copied to clipboard
Sending a GET Request with Token
To send a GET request with an authentication token:
void main() async {
try {
var response = await ApiMethods().getMethodWithToken(
url: "https://api.example.com/data",
token: "your_token_here"
);
print(response);
} catch (e) {
print("Error: $e");
}
}
copied to clipboard
Sending a POST Request
To send a basic POST request:
void main() async {
try {
var response = await ApiMethods().postMethod(
url: "https://api.example.com/data",
body: jsonEncode({"key": "value"})
);
print(response);
} catch (e) {
print("Error: $e");
}
}
copied to clipboard
Sending a POST Request with Token
To send a POST request with an authentication token:
void main() async {
try {
var response = await ApiMethods().postMethodWithToken(
url: "https://api.example.com/data",
token: "your_token_here",
body: jsonEncode({"key": "value"})
);
print(response);
} catch (e) {
print("Error: $e");
}
}
copied to clipboard
nex_common_api #
nex_common_api #

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.