1:
res, err := json.Marshal(data)
if err != nil {
app.logger.Println(err)
http.Error(w, "There was an error marshalling the data", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(res))```
2.
```w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
json.NewEncoder(w).Encode(data)```
and why?