Skip to content

Commit

Permalink
fix(useFetch): uppercase HTTP methods in useFetch (#1336)
Browse files Browse the repository at this point in the history
Co-authored-by: Nurettin Kaya <sibbngheid@gmail.com>
  • Loading branch information
Glandos and sibbng committed Mar 2, 2022
1 parent 5f5fd9d commit 4ce7c72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions packages/core/useFetch/index.ts
Expand Up @@ -89,7 +89,7 @@ export interface UseFetchReturn<T> {
}

type DataType = 'text' | 'json' | 'blob' | 'arrayBuffer' | 'formData'
type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options'
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'

const payloadMapping: Record<string, string> = {
json: 'application/json',
Expand Down Expand Up @@ -265,7 +265,7 @@ export function useFetch<T>(url: MaybeRef<string>, ...args: any[]): UseFetchRetu
let options: UseFetchOptions = { immediate: true, refetch: false, timeout: 0 }
interface InternalConfig { method: HttpMethod; type: DataType; payload: unknown; payloadType?: string }
const config: InternalConfig = {
method: 'get',
method: 'GET',
type: 'text' as DataType,
payload: undefined as unknown,
}
Expand Down Expand Up @@ -442,13 +442,13 @@ export function useFetch<T>(url: MaybeRef<string>, ...args: any[]): UseFetchRetu
onFetchError: errorEvent.on,
onFetchFinally: finallyEvent.on,
// method
get: setMethod('get'),
put: setMethod('put'),
post: setMethod('post'),
delete: setMethod('delete'),
patch: setMethod('patch'),
head: setMethod('head'),
options: setMethod('options'),
get: setMethod('GET'),
put: setMethod('PUT'),
post: setMethod('POST'),
delete: setMethod('DELETE'),
patch: setMethod('PATCH'),
head: setMethod('HEAD'),
options: setMethod('OPTIONS'),
// type
json: setType('json'),
text: setType('text'),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/useStyleTag/index.md
Expand Up @@ -47,7 +47,7 @@ useStyleTag('.foo { margin-top: 32px; }', { id: 'custom-id' })
```html
<!-- injected to <head> -->
<style type="text/css" id="custom-id">
.foo { margin-top: 64px; }
.foo { margin-top: 32px; }
</style>
```

Expand All @@ -62,6 +62,6 @@ useStyleTag('.foo { margin-top: 32px; }', { media: 'print' })
```html
<!-- injected to <head> -->
<style type="text/css" id="vueuse_styletag_1" media="print">
.foo { margin-top: 64px; }
.foo { margin-top: 32px; }
</style>
```

0 comments on commit 4ce7c72

Please sign in to comment.