Remove baseURL from packages/jsonrpc#createRemoteClient

This commit is contained in:
Jerko Steiner 2019-08-30 15:01:01 +07:00
parent 19f0993088
commit 5cc20ccd8e
4 changed files with 4 additions and 8 deletions

View File

@ -80,7 +80,7 @@ describe('createActions', () => {
function getClient() {
const remoteClient = createRemoteClient<IService>(
baseUrl, '/service', keys<IService>())
baseUrl + '/service', keys<IService>())
const client = createActions(remoteClient, 'myService')
const defaultState = {

View File

@ -6,7 +6,6 @@ import {
TAllActions,
TReduxHandlers,
} from './types'
import {createRemoteClient} from './remote'
export function createActions<T, ActionType extends string>(
client: TAsyncified<T>,

View File

@ -65,7 +65,7 @@ describe('remote', () => {
describe('idempotent method invocation (GET)', () => {
it('creates a proxy for remote service', async () => {
const rpc = createRemoteClient<IService>(
baseUrl, '/myService', IServiceKeys)
baseUrl + '/myService', IServiceKeys)
const result = await rpc.fetchItem({a: 10}, {b: 20})
expect(result).toEqual({a: 10, b: 20})
})
@ -74,7 +74,7 @@ describe('remote', () => {
describe('method invocation (POST)', () => {
it('creates a proxy for remote service', async () => {
const rpc = createRemoteClient<IService>(
baseUrl, '/myService', IServiceKeys)
baseUrl + '/myService', IServiceKeys)
const result = await rpc.add(3, 7)
expect(result).toBe(3 + 7)
})

View File

@ -8,15 +8,12 @@ export const createNumberGenerator = (val: number) => () => ++val
export const constantId = (val: string) => () => val
export function createRemoteClient<T>(
baseUrl: string,
url: string,
methods: Array<FunctionPropertyNames<T>>,
getNextRequestId: TRequestIdGenerator<string | number> = constantId('c'),
idempotentMethodRegex = IDEMPOTENT_METHOD_REGEX,
) {
const axios = Axios.create({
baseURL: baseUrl,
})
const axios = Axios.create()
async function createRequest(
id: string | number | null,