add token to request
This commit is contained in:
+9
-5
@@ -36,11 +36,15 @@ func (client Client) GenerateContent(message string) (string, error) {
|
|||||||
|
|
||||||
payloadBytes, _ := json.Marshal(payload)
|
payloadBytes, _ := json.Marshal(payload)
|
||||||
|
|
||||||
res, err := client.http.Post(
|
req, err := http.NewRequest("POST", client.endpoint, bytes.NewBuffer(payloadBytes))
|
||||||
client.endpoint,
|
if err != nil {
|
||||||
"application/json",
|
return "", err
|
||||||
bytes.NewBuffer(payloadBytes),
|
}
|
||||||
)
|
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", client.token))
|
||||||
|
|
||||||
|
res, err := client.http.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user