Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ferreiravinicius opened this issue Sep 12, 2019 · 1 comment

Comments

@ferreiravinicius
Copy link

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

@SpurguX
Copy link

SpurguX commented Sep 4, 2020

I'm encountering the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants