haskell-servant / haskell-servant/servant-js

How about append default header for axios and typescript style.

Open
#40 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
23
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Hi there, very thanks to make js interface from type based safety api!

I used 'type to axios style api', and thought that it is more useful for development(flexibility) to inject default header "Content-value 'application/json'" and body as {}(this maybe axios behavior likely bug. When none body is passed, header is not inject if header value is passed.).

How about inject axios default header Content-Type 'application/json' and body as {} or merged with body like {...body}?
Example output like below.
```
export interface XRequest {
xId: XID;
message: string;
}

// this setting supports cors(of course when server support)
export const postX = (body: XRequest) => {
return axios.post(
endpoint + "/conv",
{ ...body },
{
headers: {
"Content-Type": "application/json"
}
}
);
};
```

I think it is easy to fix and provide more seamless work for api with client lib also under development environment.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.