Skip to content

JSONP callback #4677

@aCard0s0

Description

@aCard0s0

Greeting,
I getting a error using jsonp link to get some data. I can receive it without using a angular-cli project, but I wanna do the effort to use it. I didn't change any config code. I realize there a issue almost the same as my 8153, but anything there help me.
There a image of my error
My backend is done ASP.NET C#.
There a example of the link I'm using
http://xxx.xxx.xxx.xxx:0000/api/dashboard/serverStatus?callback=JSONP_CALLBACK
and return
/**/ typeof JSONP_CALLBACK === 'function' && JSONP_CALLBACK({"SIJStatus":{"status":200,"text":"OK"},"DJEStatus":{"status":200,"text":"OK"},"OACVStatus":{"status":200,"text":"OK"},"IdentityStatus":{"status":200,"text":"OK"},"ITopStatus":{"status":200,"text":"OK"}});
using Headers() or URLSearchParams, happens the same.

There the code from service:
`
import { Observable } from 'rxjs/Rx';
import { Injectable } from '@angular/core';
import { Jsonp } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';

getServer() {
return this.jsonp.get(this.statusURL)
.map(res => res.json() )
.catch(error => Observable.throw(error)
);
}
**There the code from module**
import { HttpModule, JsonpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { ServerStatusService } from './app.service';

@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
JsonpModule
],
providers: [
ServerStatusService
],
bootstrap: [AppComponent]
})
`

There the code from component
`
import { Component } from '@angular/core';
import { ServerStatusModel } from './app.model';
import { ServerStatusService } from './app.service';

@component({
selector: 'app-root',
templateUrl: './app.component.html',
//styleUrls: ['./app.component.css']
providers: [ServerStatusService]
})
export class AppComponent {

private errorMessage: string;
private serverStatus: ServerStatusModel;

constructor(
    private guiasService: ServerStatusService
) { }

ngAfterViewInit(){
    this.refreshInfo();
}

refreshInfo(){
    let response: any[];
    this.guiasService.getServer()
        .subscribe(
            res => { 
                response = res;
                console.log(response);         // debug
            },
            err => {
                this.errorMessage = err;
                console.log(this.errorMessage);  // debug
            },
            () =>  {
                this.serverStatus = new ServerStatusModel();
                this.serverStatus.fill(response);
                console.log(this.serverStatus);
                //this.proc.configPanel();
                //this.updatePanelArr();
            }
        );
}

}
`

OS?

Windows10

Versions.

angular-cli: 1.0.0-beta.26
node: 6.9.5

Thank you in advance for the time.

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