fix api data decoding

This commit is contained in:
Nihaal Sharma committed 2026-03-16 17:44:14 +00:00
1 parent 1feb27c721
commit 204bc10a07
3 files changed
+9 -9

No files matched your search

+3 -3
View File
@@ -38,10 +38,10 @@ class GifHoarder: Hoarder, ObservableObject {
Task { Task {
do { do {
async let (data, _) = try URLSession.shared.data(from: components!.url!) async let (data, _) = try URLSession.shared.data(from: components!.url!)
let object = let object: Trending = try JSONDecoder().decode(Trending.self, from: await data)
print(try JSONDecoder().decode(Trending.self, from: await data)) print(object.data.count)
} catch { } catch {
print(error.localizedDescription) print(error)
} }
} }
} }
+5 -5
View File
@@ -18,13 +18,13 @@ struct GifObject: Codable, Identifiable {
var source: String var source: String
var rating: String var rating: String
var content_url: String? var content_url: String?
var user: GiphyUser var user: GiphyUser?
var source_tld: String var source_tld: String
var source_post_url: String var source_post_url: String
var update_datetime: Date var update_datetime: String?
var create_datetime: Date var create_datetime: String?
var import_datetime: Date var import_datetime: String
var trending_datetime: Date var trending_datetime: String?
var images: GiphyImages var images: GiphyImages
var title: String var title: String
var alt_text: String var alt_text: String
+1 -1
View File
@@ -47,7 +47,7 @@ struct GiphyImages: Codable {
var original_still: still var original_still: still
//15s looping version //15s looping version
var looping: looping // var looping: looping
//mp4 format 50kb, first 1-2s of the gif //mp4 format 50kb, first 1-2s of the gif
var preview: video var preview: video
//50kb first 1-2s of the gif //50kb first 1-2s of the gif
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.