Skip to content

xhr-http-post-json returns : "Warning: unreachable code after return statement" #1069

Closed
@serge-hulne

Description

@serge-hulne

Machine used: Mac mini M1 silicon chip.
Browser used: FireFox 92.0.1
GopherJS : GopherJS 1.17.0+go1.17.1
Go version : go version go1.17 darwin/arm64

I tried the "POST" request example using xhr from: https://siongui.github.io/2016/01/21/go-xhr-http-post-json-by-gopherjs/

I get the following warning in the browser tools (client-side: FireFox):

unreachable code after return statement

and on the serve side (in terminal), the output from is:

	print(d.Title)
	print(d.Data)

is

testnone  

Apparently, the error comes from this part of the example (the call to the Post method on the client side):

	resp, err := http.Post("/post", "application/json", strings.NewReader(jsonStr))

	if err != nil {
		// handle error
		println(err)
	}
	defer resp.Body.Close()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions