Skip to content

Commit

Permalink
api header instruction in README
Browse files Browse the repository at this point in the history
  • Loading branch information
MOKTADIR authored and MOKTADIR committed Apr 12, 2023
1 parent 8719a3a commit 6fe8518
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,21 @@ After setting up all the needed thing now lets talk about folder structure which

**GET**

**CHANG THE HEADER in the DIO_CLIENT.DART file according to you >> "defaultHeader" to "secureHeader" . in MULTIPART "defaultMultipartHeader" to "secureMultipartHeader"**

```dart
final postList = RxList<Posts>();
getPostList() async {
getPostDetail(int? id) async {
showLoading();
var response = await DioClient().get(url: ApiUrl.allPosts, header: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}).catchError(handleError);
var response = await DioClient()
.get(url: "${ApiUrl.postDetail}$id")
.catchError(handleError);
if (response == null) return;
postList
.assignAll((response as List).map((e) => Posts.fromJson(e)).toList());
title = response["title"].toString();
body = response["body"].toString();
hideLoading();
Get.to(() => const PostDetailView(), binding: HomeBinding());
}
```

Expand All @@ -283,7 +282,7 @@ After setting up all the needed thing now lets talk about folder structure which
var response = await DioClient()
.post(
url: ApiUrl.createHrAward,
header: {"Authorization": "Bearer ${await MySharedPref.getToken()}"},
body: request)
.catchError(handleError);
if (response == null) return;
Expand All @@ -309,10 +308,7 @@ After setting up all the needed thing now lets talk about folder structure which
var response = await DioClient()
.multipartSingleFile(
url: ApiUrl.updateProfile,
header: {
"Authorization": "Bearer ${await MySharedPref.getToken()}",
'Content-Type': 'multipart/form-data'
},
body: request,
filepath: filePath,
key: "profile")
Expand Down

0 comments on commit 6fe8518

Please sign in to comment.