Skip to content

Commit

Permalink
grafana#1289: Removed extra parameter as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vanshaj committed Jul 6, 2022
1 parent ffe5fd1 commit 44b3c82
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions js/modules/k6/http/request.go
Expand Up @@ -437,26 +437,24 @@ func (c *Client) prepareBatchObject(requests map[string]interface{}) (

// Batch makes multiple simultaneous HTTP requests. The provideds reqsV should be an array of request
// objects. Batch returns an array of responses and/or error
func (c *Client) Batch(reqsValues ...goja.Value) (interface{}, error) {
func (c *Client) Batch(reqsV ...goja.Value) (interface{}, error) {
state := c.moduleInstance.vu.State()
if state == nil {
return nil, ErrBatchForbiddenInInitContext
}

if len(reqsValues) == 0 {
if len(reqsV) == 0 {
return nil, fmt.Errorf("no argument was provided to http.batch()")
} else if len(reqsValues) > 1 {
} else if len(reqsV) > 1 {
return nil, fmt.Errorf("http.batch() accepts only an array or an object of requests")
}

reqsV := reqsValues[0]
var (
err error
batchReqs []httpext.BatchParsedHTTPRequest
results interface{} // either []*Response or map[string]*Response
)

switch v := reqsV.Export().(type) {
switch v := reqsV[0].Export().(type) {
case []interface{}:
batchReqs, results, err = c.prepareBatchArray(v)
case map[string]interface{}:
Expand Down

0 comments on commit 44b3c82

Please sign in to comment.