show Query String Parameters

addon-dailer
lqqyt2423 3 years ago
parent b269bb9dd8
commit b2ba27f4c4

@ -34,7 +34,7 @@ class ViewFlow extends React.Component<Iprops, IState> {
const { flow } = this.props const { flow } = this.props
if (!flow) return null if (!flow) return null
const response = flow.response const response = flow.response
if(!response) return null if (!response) return null
if (!(response.body && response.body.byteLength)) { if (!(response.body && response.body.byteLength)) {
return <div style={{ color: 'gray' }}>No response</div> return <div style={{ color: 'gray' }}>No response</div>
@ -62,6 +62,14 @@ class ViewFlow extends React.Component<Iprops, IState> {
const request = flow.request const request = flow.request
const response: IResponse = (flow.response || {}) as any const response: IResponse = (flow.response || {}) as any
// Query String Parameters
const searchItems: Array<{ key: string; value: string }> = []
if (flow.url && flow.url.search) {
flow.url.searchParams.forEach((value, key) => {
searchItems.push({ key, value })
})
}
return ( return (
<div className="flow-detail"> <div className="flow-detail">
<div className="header-tabs"> <div className="header-tabs">
@ -100,7 +108,7 @@ class ViewFlow extends React.Component<Iprops, IState> {
{ {
!(flowTab === 'Headers') ? null : !(flowTab === 'Headers') ? null :
<div> <div>
<p><Button size="sm" variant={ this.state.copied ? 'success' : 'primary' } disabled={this.state.copied} onClick={() => { <p><Button size="sm" variant={this.state.copied ? 'success' : 'primary'} disabled={this.state.copied} onClick={() => {
const curl = fetchToCurl({ const curl = fetchToCurl({
url: flow.request.url, url: flow.request.url,
method: flow.request.method, method: flow.request.method,
@ -118,7 +126,7 @@ class ViewFlow extends React.Component<Iprops, IState> {
}, 1000) }, 1000)
}) })
}}>{ this.state.copied ? 'Copied' : 'Copy as cURL' }</Button></p> }}>{this.state.copied ? 'Copied' : 'Copy as cURL'}</Button></p>
<div className="header-block"> <div className="header-block">
<p>General</p> <p>General</p>
@ -159,6 +167,22 @@ class ViewFlow extends React.Component<Iprops, IState> {
</div> </div>
</div> </div>
{
!(searchItems.length) ? null :
<div className="header-block">
<p>Query String Parameters</p>
<div className="header-block-content">
{
searchItems.map(({ key, value }) => {
return (
<p key={key}>{key}: {value}</p>
)
})
}
</div>
</div>
}
{ {
!(request.body && request.body.byteLength) ? null : !(request.body && request.body.byteLength) ? null :
<div className="header-block"> <div className="header-block">

@ -55,7 +55,7 @@ export class Flow {
public request: IRequest public request: IRequest
public response: IResponse | null = null public response: IResponse | null = null
private url: URL public url: URL
private path: string private path: string
private _size = 0 private _size = 0
private size = '0' private size = '0'

Loading…
Cancel
Save