4. HTTP URLs

A URL, or Uniform Resource Locatorarrow-up-right, is the address of another computer, or "server" on the internet. Part of the URL specifies where to reach the server, and part of it tells the server what information we want.

![[Pasted image 20260206003813.png]]

Put simply, a URL represents a piece of information on some computer somewhere. We can get access to it by making a request, and reading the response that the server replies with.

Assignment

1

Run the code

Try running the code in its current state. You should notice an error because the URL we're using is invalid.

2

Fix the code

Fix the code so that the call to getIssueData uses the provided issueURL.

This time the printed data won't be as ugly, I added a prettify function that adds some formatting.

Original (buggy) code:

main.go
package main

import (
	"fmt"
	"log"
)

const issueURL = "https://api.boot.dev/v1/courses_rest_api/learn-http/issues"

func main() {
	issues, err := getIssueData(issueUrl) // input here
	if err != nil {
		log.Fatalf("error getting issue data: %v", err)
	}
	prettyData, err := prettify(string(issues))
	if err != nil {
		log.Fatalf("error prettifying data: %v", err)
	}
	fmt.Println(prettyData)
}

Fixed code (use the correctly cased constant issueURL):