Skip to content

axios complains about adapter field in config object #79

Description

@ismanf

This code example on js-data-http guid simply does not work for me:

import { Container } from 'js-data';
import { HttpAdapter } from 'js-data-http-node';

const httpAdapter = new HttpAdapter({
	basePath: 'https://mydomain.com'
});
const store = new Container();

store.registerAdapter('http', httpAdapter, { 'default': true });

store.defineMapper('school');
store.defineMapper('student');

// GET /school/1
store.find('school', 1).then((school) => {
  console.log('school');
});

It throws error:

TypeError: adapter is not a function at dispatchRequest (/Users/ismail.niftaliev/Documents/demo/dummy_server/node_modules/axios/lib/core/dispatchRequest.js:59:10) at <anonymous> at process._tickCallback (internal/process/next_tick.js:189:7) at Function.Module.runMain (module.js:696:11) at startup (bootstrap_node.js:204:16) at bootstrap_node.js:625:3

The problem is in config object which you send to axios
you set adapter: 'http'
and axios first checks if config has an adapter then uses it if not uses default adapter and then calls it as a function, so while you set a string as a value for adapter it makes axios crazy.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions