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

Subscribe executing twice times. #2

Open
daibertdiego opened this issue Apr 11, 2018 · 0 comments
Open

Subscribe executing twice times. #2

daibertdiego opened this issue Apr 11, 2018 · 0 comments

Comments

@daibertdiego
Copy link

Subscribe executing twice times.

I'm having problems to use the library with HttpClient because when I call the subscribe, the method returns a result from Options request and after the result from GET,POST,PUT,DELETE request. And this behavior doesn't happen when I user the HttpClient directly.
I'm really want to continue using your library because It's one that already uses HttpClient and now I'm having a necessity to use the HttpInterceptors in my project. Before this, I was using https://www.npmjs.com/package/ng2-http but they don't have global interceptors support yet.

When I use raw HttpClient like this, the result of subscribe is correct.

let post = this.http.post(apiEndpoint + 'core/company/find-user-companies', this.model, { headers: new HttpHeaders().set('Content-Type', 'application/json') }); post.subscribe((res) => { console.log('COMPANY SEM LIB', res); });

But when I use the Library, the result is first undefined and after the correct response.

`@Injectable()
export class CompanyService extends RestClient {

constructor(http: HttpClient) {
    super(http);
}

@Post('/company/find-user-companies')
@Produces(MediaType.JSON)
public findUserCompanies(@Body credentials: any): Observable<Company[]> {
    return null;
}

...
}`

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

1 participant