diff --git a/js/modules/k6/http/request.go b/js/modules/k6/http/request.go index f8c39e5c1b81..fc54e820af2d 100644 --- a/js/modules/k6/http/request.go +++ b/js/modules/k6/http/request.go @@ -93,8 +93,8 @@ func (c *Client) asyncRequest(method string, url goja.Value, args ...goja.Value) req, err := c.parseRequest(method, url, body, params) p, resolve, reject := rt.NewPromise() if err != nil { - resp, err := c.handleParseRequestError(err) - if err != nil { + var resp *Response + if resp, err = c.handleParseRequestError(err); err != nil { reject(err) } else { resolve(resp)