Closed
Description
Error: Post http://127.0.0.1:8881: dial tcp 127.0.0.1:8881: setsockopt: bad address at $callDeferred (/js/testhttp.js:1412:17) at $panic (/js/testhttp.js:1451:3) at getDataFromPost (/js/testhttp.js:109234:4) at Object.v.$externalizeWrapper [as testhttprpc] (/js/testhttp.js:1867:24) at Object. (/js/testrpc.js:13:6) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:390:7) at startup (bootstrap_node.js:150:9) at bootstrap_node.js:505:3
url := "http://127.0.0.1:8881"
fmt.Println("URL:>", url)
var jsonStr = []byte(`{"id": 2}`)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{
Transport: &http.Transport{
MaxIdleConnsPerHost: 5,
},
}
resp, err := client.Do(req) // this line caused error
if err != nil {
panic(err)
}
Does gopherjs support net/http module in golang ?