javascript-xhr.js (hoppscotch-2.0.0) | : | javascript-xhr.js (hoppscotch-2.1.0) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
rawParams, | rawParams, | |||
rawRequestBody, | rawRequestBody, | |||
contentType, | contentType, | |||
}) => { | }) => { | |||
const requestString = [] | const requestString = [] | |||
requestString.push("const xhr = new XMLHttpRequest()") | requestString.push("const xhr = new XMLHttpRequest()") | |||
const user = auth === "Basic Auth" ? `'${httpUser}'` : null | const user = auth === "Basic Auth" ? `'${httpUser}'` : null | |||
const password = auth === "Basic Auth" ? `'${httpPassword}'` : null | const password = auth === "Basic Auth" ? `'${httpPassword}'` : null | |||
requestString.push( | requestString.push( | |||
`xhr.open('${method}', '${url}${pathName}${queryString}', true, ${user}, $ {password})` | `xhr.open('${method}', '${url}${pathName}?${queryString}', true, ${user}, ${password})` | |||
) | ) | |||
if (auth === "Bearer Token" || auth === "OAuth 2.0") { | if (auth === "Bearer Token" || auth === "OAuth 2.0") { | |||
requestString.push( | requestString.push( | |||
`xhr.setRequestHeader('Authorization', 'Bearer ${bearerToken}')` | `xhr.setRequestHeader('Authorization', 'Bearer ${bearerToken}')` | |||
) | ) | |||
} | } | |||
if (headers) { | if (headers) { | |||
headers.forEach(({ key, value }) => { | headers.forEach(({ key, value }) => { | |||
if (key) | if (key) | |||
requestString.push(`xhr.setRequestHeader('${key}', '${value}')`) | requestString.push(`xhr.setRequestHeader('${key}', '${value}')`) | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added |