fixed giphy api call

This commit is contained in:
neon443 committed 2026-03-15 21:35:44 +00:00
1 parent dfb21ddc3a
commit 224269a849
1 file changed
+11 -6
+11 -6
View File
@@ -13,6 +13,7 @@ import Combine
class GifHoarder: Hoarder, ObservableObject {
static let container: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
static var apiKey: String = ""
var endpoint: URL = URL(string: "https://api.giphy.com/v1/gifs/trending")!
var endpointSearch: URL = URL(string: "https://api.giphy.com/v1/gifs/search")!
@@ -29,14 +30,18 @@ class GifHoarder: Hoarder, ObservableObject {
}
init() {
var request = URLRequest(url: endpoint)
request.setValue("", forHTTPHeaderField: "api_key")
request.setValue("100", forHTTPHeaderField: "limit")
var components = URLComponents(url: endpoint, resolvingAgainstBaseURL: false)
components?.queryItems = [
URLQueryItem(name: "api_key", value: GifHoarder.apiKey),
URLQueryItem(name: "limit", value: "100")
]
Task {
do {
async let (data, _) = try URLSession.shared.data(from: endpoint)
dump(await data)
print(await data.base64EncodedString())
async let (data, _) = try URLSession.shared.data(from: components!.url!)
dump(try await data)
print(try await data.base64EncodedString())
} catch {
print(error.localizedDescription)
}
}
}
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.