8000 Fix resolving requests of custom resources · PQS-LAB/vue-api-query@222addb · GitHub
[go: up one dir, main page]

Skip to content

Commit 222addb

Browse files
committed
Fix resolving requests of custom resources
1 parent f9f4cec commit 222addb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export default class Model extends StaticModel {
255255

256256
get() {
257257
let base = this._fromResource || `${this.baseURL()}/${this.resource()}`
258-
base = this._customResource || base
258+
base = this._customResource ? `${this.baseURL()}/${this._customResource}` : base
259259
let url = `${base}${this._builder.query()}`
260260

261261
return this.request({

tests/model.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ describe('Model methods', () => {
303303
test('a request with custom() method hits the right resource', async () => {
304304

305305
axiosMock.onAny().reply((config) => {
306-
expect(config.url).toBe('postz')
306+
expect(config.url).toEqual(`http://localhost/postz`)
307307

308308
return [200, {}]
309309
})
@@ -314,7 +314,7 @@ describe('Model methods', () => {
314314
test('custom() gracefully handles accidental / for string arguments', async () => {
315315

316316
axiosMock.onAny().reply((config) => {
317-
expect(config.url).toBe('postz/recent')
317+
expect(config.url).toBe('http://localhost/postz/recent')
318318

319319
return [200, {}]
320320
})
@@ -328,7 +328,7 @@ describe('Model methods', () => {
328328

329329
axiosMock.onAny().reply((config) => {
330330
expect(config.method).toEqual('get')
331-
expect(config.url).toEqual('users/1/postz/comments')
331+
expect(config.url).toEqual('http://localhost/users/1/postz/comments')
332332

333333
return [200, {}]
334334
})

0 commit comments

Comments
 (0)
0