Skip to content

Commit 443d56e

Browse files
committed
πŸš‘ Restrict requests with numbers
1 parent 98bf109 commit 443d56e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

β€ŽREADME.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ It's also possible to create extended version of existing by providing additiona
243243
const posts = api.extend({ resource: '/posts' })
244244

245245
await posts.get().json() // β†’ [{ id: 0, title: 'Hello' }, ...]
246-
await posts.get(0).json() // β†’ { id: 0, title: 'Hello' }
246+
await posts.get('/1').json() // β†’ { id: 0, title: 'Hello' }
247247
await posts.post({ json: { title: 'Bye' } }).json() // β†’ { id: 1, title: 'Bye' }
248-
await posts.patch(0, { json: { title: 'Hey' } }).json() // β†’ { id: 0, title: 'Hey' }
249-
await posts.delete(1).void() // β†’ undefined
248+
await posts.patch('/0', { json: { title: 'Hey' } }).json() // β†’ { id: 0, title: 'Hey' }
249+
await posts.delete('/1').void() // β†’ undefined
250250
```
251251

252252
#### Related
@@ -385,7 +385,7 @@ const extended = instance.extend({
385385
})
386386
387387
// will send request to: 'https://jsonplaceholder.typicode.com/posts/1'
388-
await extended.post(1, { json: { title: 'Hello' } })
388+
await extended.post('/1', { json: { title: 'Hello' } })
389389
```
390390

391391
##### Related

β€Žsrc/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface Serialize {
2828

2929
interface RequestMethod<P extends Payload> {
3030
<T extends P>(
31-
resource?: number | string | RequestMethodOptions<T>,
31+
resource?: string | RequestMethodOptions<T>,
3232
options?: RequestMethodOptions<T>
3333
): ResponsePromise<T>
3434
}

0 commit comments

Comments
Β (0)