import React, { PropTypes } from "react"
import ImPropTypes from "react-immutable-proptypes"
const Headers = ( { headers } )=>{
return (
Response headers
{headers}
)
}
Headers.propTypes = {
headers: PropTypes.array.isRequired
}
const Duration = ( { duration } ) => {
return (
Request duration
{duration} ms
)
}
Duration.propTypes = {
duration: PropTypes.number.isRequired
}
export default class LiveResponse extends React.Component {
static propTypes = {
response: PropTypes.object.isRequired,
getComponent: PropTypes.func.isRequired
}
render() {
const { request, response, getComponent } = this.props
const status = response.get("status")
const url = response.get("url")
const headers = response.get("headers").toJS()
const notDocumented = response.get("notDocumented")
const isError = response.get("error")
const duration = response.get("duration")
const body = isError ? response.get("response").get("text") : response.get("text")
const headersKeys = Object.keys(headers)
const contentType = headers["content-type"]
const Curl = getComponent("curl")
const ResponseBody = getComponent("responseBody")
const returnObject = headersKeys.map(key => {
return {key}: {headers[key]}
})
const hasHeaders = returnObject.length !== 0
return (
{ request &&
}
Server response
| Code |
Details |
|
{ status }
{
notDocumented ?
Undocumented
: null
}
|
{
isError ?
{`${response.get("name")}: ${response.get("message")}`}
: null
}
{
body ?
: null
}
{
hasHeaders ? : null
}
{
duration ? : null
}
|
)
}
static propTypes = {
getComponent: PropTypes.func.isRequired,
request: ImPropTypes.map,
response: ImPropTypes.map
}
}