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

Wrong behaviour when extends from Http #611

Closed
2 of 10 tasks
antonbarada opened this issue Oct 27, 2016 · 4 comments
Closed
2 of 10 tasks

Wrong behaviour when extends from Http #611

antonbarada opened this issue Oct 27, 2016 · 4 comments

Comments

@antonbarada
Copy link

  • I'm submitting a ...
  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.
  • What modules are related to this Issue?
  • express-engine
  • grunt-prerender
  • gulp-prerender
  • hapi-engine
  • universal-next
  • universal
  • webpack-prerender
  • Do you want to request a feature or report a bug?
    Report a bug
  • What is the current behavior?
    Using class for customize http requests and extends from Http
    asynchronous data, that fetched from server, does not rendered (serverside)
    Also, setTimeout does not block application

Current behavior
In response Home component looks like

Home component
<p>Hi! My name is </p>
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

repo - thebarada/universal-starter

commit - thebarada/universal-starter#be67335

Just run npm start

  • What is the expected behavior?
    In response Home component should looks like
Home component
<p>Hi! My name is name after timeout</p>
  • What is the motivation / use case for changing the behavior?
    In my case I tried set meta tags for sharing, but it impossible
  • Please tell us about your environment:
  • Angular version: 2.1.0
  • Browser: all
  • Language: TypeScript 2.0.2
  • OS: macOs Siera
  • Platform: NodeJs
@MarkPieszak
Copy link
Member

I couldn't get your repo working for some reason, but tested it in a different one.

So the problem is that we're already extending Http inside Universal, but if you want to extend that even further... Just extend our class even further.

import { PreloadHttp } from 'angular2-universal';

@Injectable()
export class MyHttpService extends PreloadHttp {
  constructor(backend: XHRBackend, defaultOptions: RequestOptions) {
    defaultOptions.headers.append(
      'Content-Type',
      'application/json; charset=utf-8'
    );
    super(backend, defaultOptions);
  }
}

That should do the trick! Let me know if you run into any problems.

@MarkPieszak
Copy link
Member

@gdi2290 Is there another way you'd prefer that people do this?

@MarkPieszak MarkPieszak reopened this Nov 22, 2016
@PatrickJS
Copy link
Member

won't be supported in ng4
angular/angular#13822

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants