@@ -8,6 +8,7 @@ public final class PostViewModel: ObservableObject {
8
8
private let emojiProvider = MoyaProvider < EmojiAPI > (
9
9
plugins: [ NetworkLoggerPlugin ( configuration: . init( logOptions: . verbose) ) ]
10
10
)
11
+ private let userProvider = MoyaProvider < UserAPI > ( )
11
12
private var title : String = " "
12
13
private var accessToken : String = " Bearer eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiIyIiwiaWF0IjoxNzM0NjYyNTg4LCJleHAiOjE3NDQ2NjI1ODh9.FG4FVQ4oikC4HNy5h7gq0QyCIjVZtceIOKwAMnkULAt4y0lX5gGIF1s2Mdj9qr1H "
13
14
private var userList : [ Int ] = [ ]
@@ -24,6 +25,7 @@ public final class PostViewModel: ObservableObject {
24
25
@Published var myPostList : [ MyPostListResponse ] = [ ]
25
26
@Published var myReactionPostList : [ MyReactionPostListResponse ] = [ ]
26
27
@Published var popularityPostList : [ PopularityResponse ] = [ ]
28
+ @Published public var myInfo : MyInfoResponse ?
27
29
private var imageUploadResponse : ImageUploadResponse ?
28
30
29
31
@@ -202,18 +204,13 @@ public final class PostViewModel: ObservableObject {
202
204
}
203
205
204
206
public func myInfo( completion: @escaping ( Bool ) -> Void ) {
205
- authProvider . request ( . popularityUserList ( authorization: accessToken) ) { result in
207
+ userProvider . request ( . userInfoInput ( authorization: accessToken) ) { result in
206
208
switch result {
207
209
case let . success( response) :
208
210
do {
209
211
print ( " 성공: 유저 리스트 불러오기 " )
210
212
211
- self . popularityUserList = try JSONDecoder ( ) . decode ( [ PopularityRankingUserListResponse ] . self, from: response. data)
212
-
213
- print ( " 불러온 유저 리스트: " )
214
- for (index, user) in self . popularityUserList. enumerated ( ) {
215
- print ( " [ \( index) ] \( user) " )
216
- }
213
+ self . myInfo = try JSONDecoder ( ) . decode ( MyInfoResponse . self, from: response. data)
217
214
218
215
completion ( true )
219
216
} catch {
0 commit comments