File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import { IErrorResponse } from '../models/error-response';
10
10
import { AlertService } from './alert.service' ;
11
11
import { PostFileMapManager } from './post-file-map' ;
12
12
import { ZzkSearchResult } from '../models/zzk-search-result' ;
13
- import { got , gotWithBuffer } from '@/utils/http-client' ;
13
+ import got from '@/utils/http-client' ;
14
+ import httpClient from '@/utils/http-client' ;
14
15
import iconv from 'iconv-lite' ;
15
16
16
17
const defaultPageSize = 30 ;
@@ -69,7 +70,10 @@ export class PostService {
69
70
}
70
71
71
72
async fetchPostEditDto ( postId : number , muteErrorNotification = false ) : Promise < PostEditDto | undefined > {
72
- const response = await gotWithBuffer ( `${ this . _baseUrl } /api/posts/${ postId } ` ) ;
73
+ const response = await httpClient . get ( `${ this . _baseUrl } /api/posts/${ postId } ` , {
74
+ throwHttpErrors : false ,
75
+ responseType : 'buffer' ,
76
+ } ) ;
73
77
74
78
try {
75
79
throwIfNotOkGotResponse ( response ) ;
Original file line number Diff line number Diff line change @@ -20,15 +20,6 @@ const httpClient = got.extend({
20
20
https : { rejectUnauthorized : false } ,
21
21
} ) ;
22
22
23
- const gotWithBuffer = got . extend ( {
24
- hooks : {
25
- beforeRequest : [ bearerTokenHook ] ,
26
- } ,
27
- throwHttpErrors : false ,
28
- https : { rejectUnauthorized : false } ,
29
- responseType : 'buffer' ,
30
- } ) ;
31
-
32
- export { got , gotWithBuffer } ;
23
+ export { got } ;
33
24
export * from 'got' ;
34
25
export default httpClient ;
Original file line number Diff line number Diff line change 1
1
import { GotFetchResponse } from 'got-fetch/out/lib/response' ;
2
2
import { Response as GotResponse } from 'got' ;
3
3
import { IErrorResponse , isErrorResponse } from '../models/error-response' ;
4
+ import iconv from 'iconv-lite' ;
4
5
5
6
const throwIfNotOkResponse = async ( response : GotFetchResponse ) => {
6
7
if ( ! response . ok ) {
@@ -21,9 +22,9 @@ const throwIfNotOkResponse = async (response: GotFetchResponse) => {
21
22
}
22
23
} ;
23
24
24
- const throwIfNotOkGotResponse = ( response : GotResponse < string > ) => {
25
+ const throwIfNotOkGotResponse = ( response : GotResponse < Buffer > ) => {
25
26
if ( ! response . ok ) {
26
- const responseText = response . body ;
27
+ const responseText = iconv . decode ( response . rawBody , 'utf-8' ) ;
27
28
let responseJson : unknown ;
28
29
try {
29
30
responseJson = JSON . parse ( responseText ) ;
You can’t perform that action at this time.
0 commit comments