Skip to content

Commit

Permalink
Merge pull request #16 from adityacodes30/main
Browse files Browse the repository at this point in the history
Return all links as an array of objects
  • Loading branch information
MankiratSingh1315 authored Jun 13, 2024
2 parents 9df324f + 97eda13 commit 85062cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func GetAllLinks(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("No links found"))
return
}
var linksData []string
for _, link := range links {
// w.Write([]byte(fmt.Sprintf("%s - %s\n", link.ShortURL, link.Link)))
linksData = append(linksData, fmt.Sprintf("%s - %s\n", link.ShortURL, link.Link))
err := json.NewEncoder(w).Encode(links)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
page.Execute(w, linksData)
}
Expand Down

0 comments on commit 85062cf

Please sign in to comment.