Hello
I want to know how to get nft informations using “GET NFT BY WALLET”
Now I’m doing get body of data, but I don’t know how to get that.
I check status code 200, and all is fine.
but, I don’t know where the code is in it getting information.
Isn’t the code “request.httpbody” means data?
but the code prints nil.
func getNFT(_ walletAddress: String){
let headers = [
"accept": "application/json",
//여기에는 moralis에서 만든 api key를 넣어줍니다.
"X-API-Key": "***"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://deep-index.moralis.io/api/v2/\(walletAddress)/nft?chain=eth&format=hex")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print("body: \(request.httpBody)");
print("httpResponse:\(httpResponse)")
}
})
//print(dataTask.response)
dataTask.resume()
}