powershell-restmethod.js (hoppscotch-2.0.0) | : | powershell-restmethod.js (hoppscotch-2.1.0) | ||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
}) => { | }) => { | |||
const methodsWithBody = ["Put", "Post", "Delete"] | const methodsWithBody = ["Put", "Post", "Delete"] | |||
const formattedMethod = | const formattedMethod = | |||
method[0].toUpperCase() + method.substring(1).toLowerCase() | method[0].toUpperCase() + method.substring(1).toLowerCase() | |||
const includeBody = methodsWithBody.includes(formattedMethod) | const includeBody = methodsWithBody.includes(formattedMethod) | |||
const requestString = [] | const requestString = [] | |||
let genHeaders = [] | let genHeaders = [] | |||
let variables = "" | let variables = "" | |||
requestString.push( | requestString.push( | |||
`Invoke-RestMethod -Method '${formattedMethod}' -Uri '${url}${pathName}${q ueryString}'` | `Invoke-RestMethod -Method '${formattedMethod}' -Uri '${url}${pathName}?${ queryString}'` | |||
) | ) | |||
const requestBody = rawInput ? rawParams : rawRequestBody | const requestBody = rawInput ? rawParams : rawRequestBody | |||
if (requestBody.length !== 0 && includeBody) { | if (requestBody.length !== 0 && includeBody) { | |||
variables = variables.concat(`$body = @'\n${requestBody}\n'@\n\n`) | variables = variables.concat(`$body = @'\n${requestBody}\n'@\n\n`) | |||
} | } | |||
if (headers) { | if (headers) { | |||
headers.forEach(({ key, value }) => { | headers.forEach(({ key, value }) => { | |||
if (key) genHeaders.push(` '${key}' = '${value}'\n`) | if (key) genHeaders.push(` '${key}' = '${value}'\n`) | |||
}) | }) | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added |