unmarshal response data

This commit is contained in:
Baipyrus 2024-04-12 10:14:25 +02:00
parent 57ac3eed34
commit 454ef40765

12
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"log" "log"
@ -130,6 +131,17 @@ func SendRequest(client *resty.Client, url string, ins []interface{}) {
// Print response status // Print response status
log.Printf("Response Status: %s\n", resp.Status()) log.Printf("Response Status: %s\n", resp.Status())
// Unmarshal response
var data Response
err = json.Unmarshal(resp.Body(), &data)
if err != nil {
log.Fatal(err)
return
}
// Print response
log.Printf("Success: %t\n", data.success)
} }
func main() { func main() {