Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_parseResponse ({ data, status, statusText, headers }) {
if (headers['content-type'] !== 'application/json') {
throw new RpcError(status, statusText, { data })
}
data = parse(data)
debug('parsed jsonrpc response', data)
if (data.error != null) {
throw new RpcError(
get(data, 'error.code', -32603),
get(data, 'error.message', 'An error occurred while processing the RPC call')
)
}
if (!has(data, 'result')) {
throw new RpcError(-32700, 'Missing `result` on the RPC call result')
}
return data.result
}
_parseResponse ({ data, status, statusText, headers }) {
if (headers['content-type'] !== 'application/json') {
throw new RpcError(status, statusText, { data })
}
data = parse(data)
debug('parsed jsonrpc response', data)
if (data.error != null) {
throw new RpcError(
get(data, 'error.code', -32603),
get(data, 'error.message', 'An error occurred while processing the RPC call')
)
}
if (!has(data, 'result')) {
throw new RpcError(-32700, 'Missing `result` on the RPC call result')
}
return data.result
}
_parseResponse ({ data, status, statusText, headers }) {
if (headers['content-type'] !== 'application/json') {
throw new RpcError(status, statusText, { data })
}
data = parse(data)
debug('parsed jsonrpc response', data)
if (data.error != null) {
throw new RpcError(
get(data, 'error.code', -32603),
get(data, 'error.message', 'An error occurred while processing the RPC call')
)
}
if (!has(data, 'result')) {
throw new RpcError(-32700, 'Missing `result` on the RPC call result')
}
return data.result