mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Handle "no body" case
This commit is contained in:
@@ -136,9 +136,9 @@ async fn send_request(
|
||||
Method::from_bytes(req.method.to_uppercase().as_bytes()).expect("Failed to create method");
|
||||
let builder = client.request(m, url_string.to_string()).headers(headers);
|
||||
|
||||
let sendable_req_result = match req.body {
|
||||
Some(b) => builder.body(b).build(),
|
||||
None => builder.build(),
|
||||
let sendable_req_result = match (req.body, req.body_type) {
|
||||
(Some(b), Some(_)) => builder.body(b).build(),
|
||||
_ => builder.build(),
|
||||
};
|
||||
|
||||
let sendable_req = match sendable_req_result {
|
||||
|
||||
@@ -31,12 +31,12 @@ export function RequestPane({ fullHeight, className }: Props) {
|
||||
() => [
|
||||
{
|
||||
value: 'body',
|
||||
label: activeRequest?.bodyType ?? 'NoBody',
|
||||
label: activeRequest?.bodyType ?? 'No Body',
|
||||
options: {
|
||||
onChange: (bodyType: string) => updateRequest.mutate({ bodyType }),
|
||||
value: activeRequest?.bodyType ?? 'nobody',
|
||||
onChange: (bodyType: string | null) => updateRequest.mutate({ bodyType }),
|
||||
value: activeRequest?.bodyType ?? null,
|
||||
items: [
|
||||
{ label: 'No Body', value: 'nobody' },
|
||||
{ label: 'No Body', value: null },
|
||||
{ label: 'JSON', value: 'json' },
|
||||
{ label: 'XML', value: 'xml' },
|
||||
{ label: 'GraphQL', value: 'graphql' },
|
||||
@@ -47,7 +47,7 @@ export function RequestPane({ fullHeight, className }: Props) {
|
||||
{ value: 'headers', label: 'Headers' },
|
||||
{ value: 'auth', label: 'Auth' },
|
||||
],
|
||||
[activeRequest?.bodyType],
|
||||
[activeRequest?.bodyType ?? 'n/a'],
|
||||
);
|
||||
|
||||
const handleBodyChange = useCallback((body: string) => updateRequest.mutate({ body }), []);
|
||||
|
||||
@@ -5,12 +5,12 @@ import { Icon } from './Icon';
|
||||
|
||||
export interface RadioDropdownItem {
|
||||
label: string;
|
||||
value: string;
|
||||
value: string | null;
|
||||
}
|
||||
|
||||
export interface RadioDropdownProps {
|
||||
value: string;
|
||||
onChange: (bodyType: string) => void;
|
||||
value: string | null;
|
||||
onChange: (value: string | null) => void;
|
||||
items: RadioDropdownItem[];
|
||||
children: DropdownProps['children'];
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ export const Tabs = memo(function Tabs({
|
||||
{tabs.map((t) => {
|
||||
const isActive = t.value === value;
|
||||
if (t.options && isActive) {
|
||||
console.log('OPTIONS', t.options, t.options?.value);
|
||||
return (
|
||||
<RadioDropdown
|
||||
key={t.value}
|
||||
|
||||
Reference in New Issue
Block a user