Remove baseURL from packages/jsonrpc#createRemoteClient
This commit is contained in:
parent
19f0993088
commit
5cc20ccd8e
@ -80,7 +80,7 @@ describe('createActions', () => {
|
|||||||
|
|
||||||
function getClient() {
|
function getClient() {
|
||||||
const remoteClient = createRemoteClient<IService>(
|
const remoteClient = createRemoteClient<IService>(
|
||||||
baseUrl, '/service', keys<IService>())
|
baseUrl + '/service', keys<IService>())
|
||||||
const client = createActions(remoteClient, 'myService')
|
const client = createActions(remoteClient, 'myService')
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import {
|
|||||||
TAllActions,
|
TAllActions,
|
||||||
TReduxHandlers,
|
TReduxHandlers,
|
||||||
} from './types'
|
} from './types'
|
||||||
import {createRemoteClient} from './remote'
|
|
||||||
|
|
||||||
export function createActions<T, ActionType extends string>(
|
export function createActions<T, ActionType extends string>(
|
||||||
client: TAsyncified<T>,
|
client: TAsyncified<T>,
|
||||||
|
|||||||
@ -65,7 +65,7 @@ describe('remote', () => {
|
|||||||
describe('idempotent method invocation (GET)', () => {
|
describe('idempotent method invocation (GET)', () => {
|
||||||
it('creates a proxy for remote service', async () => {
|
it('creates a proxy for remote service', async () => {
|
||||||
const rpc = createRemoteClient<IService>(
|
const rpc = createRemoteClient<IService>(
|
||||||
baseUrl, '/myService', IServiceKeys)
|
baseUrl + '/myService', IServiceKeys)
|
||||||
const result = await rpc.fetchItem({a: 10}, {b: 20})
|
const result = await rpc.fetchItem({a: 10}, {b: 20})
|
||||||
expect(result).toEqual({a: 10, b: 20})
|
expect(result).toEqual({a: 10, b: 20})
|
||||||
})
|
})
|
||||||
@ -74,7 +74,7 @@ describe('remote', () => {
|
|||||||
describe('method invocation (POST)', () => {
|
describe('method invocation (POST)', () => {
|
||||||
it('creates a proxy for remote service', async () => {
|
it('creates a proxy for remote service', async () => {
|
||||||
const rpc = createRemoteClient<IService>(
|
const rpc = createRemoteClient<IService>(
|
||||||
baseUrl, '/myService', IServiceKeys)
|
baseUrl + '/myService', IServiceKeys)
|
||||||
const result = await rpc.add(3, 7)
|
const result = await rpc.add(3, 7)
|
||||||
expect(result).toBe(3 + 7)
|
expect(result).toBe(3 + 7)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -8,15 +8,12 @@ export const createNumberGenerator = (val: number) => () => ++val
|
|||||||
export const constantId = (val: string) => () => val
|
export const constantId = (val: string) => () => val
|
||||||
|
|
||||||
export function createRemoteClient<T>(
|
export function createRemoteClient<T>(
|
||||||
baseUrl: string,
|
|
||||||
url: string,
|
url: string,
|
||||||
methods: Array<FunctionPropertyNames<T>>,
|
methods: Array<FunctionPropertyNames<T>>,
|
||||||
getNextRequestId: TRequestIdGenerator<string | number> = constantId('c'),
|
getNextRequestId: TRequestIdGenerator<string | number> = constantId('c'),
|
||||||
idempotentMethodRegex = IDEMPOTENT_METHOD_REGEX,
|
idempotentMethodRegex = IDEMPOTENT_METHOD_REGEX,
|
||||||
) {
|
) {
|
||||||
const axios = Axios.create({
|
const axios = Axios.create()
|
||||||
baseURL: baseUrl,
|
|
||||||
})
|
|
||||||
|
|
||||||
async function createRequest(
|
async function createRequest(
|
||||||
id: string | number | null,
|
id: string | number | null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user