Skip to content

When using doUniqueRequest the url is being duplicated (concatenated). #30

Open
@ferreiravinicius

Description

@ferreiravinicius

Description

When using doUniqueRequest with ApiService the url is being duplicated.
Using doRequest works fine.

"@apicase/adapter-fetch": "^0.15.1",
"@apicase/core": "^0.17.2",
"@apicase/services": "^0.8.2"

Reproduce

BaseService.js

/*
* Base service setting cors, fetch adapter and base url of the api 
*/
export const SimpleBaseService = new ApiService({
  adapter: fetch,
  url: "http://localhost:8080/api",
  mode: 'cors'
});

UserService.js

/*
* Just a simple hook to log the payload before each request. 
*/
const beforeLoggingRequest = ({ payload, next }) => {
  console.log("Before User Service Call");
  console.log(payload);
  next(payload);
};

/*
* Extending the base service and setting up the before hook.
*/
const UserService =  SimpleBaseService.extend({
  hooks: {
    before: beforeLoggingRequest
  }
});

Then when using with doUniqueRequest the url is being duplicated:

const { success, result } = await UserService.doUniqueRequest({
    method: "GET"
  });

This call logs:

> Before User Service Call
> {url: "http://localhost:8080/api/http://localhost:8080/api", mode: "cors", method: "GET"}
method: "GET"
mode: "cors"
url: "http://localhost:8080/portalcesa/http://localhost:8080/portalcesa"

It also throws this exception (screenshot): http://prntscr.com/p5feym

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