1

In my Angular2 App i call API EndPoint with a service

this.jsonp.request(middlewareUrl, { method: 'Get' })
            .subscribe(
                (data) => {
                    console.log(data);
                },
                (error) => {
                    console.log(error);
                });
      console.log("post data");

  }

and recive this response :

Response_body: "JSONP injected script did not invoke callback."headers: Headersok: truestatus: 200statusText: "Ok"type: 3url: "http://localhost:4000/matches?callback=__ng_jsonp__.__req0.finished"__proto__: Bodyconstructor: Response(responseOptions)toString: ()__proto__: Object

the endPoint return this:

_todayMatchesCallback({"matchlist":["match1","match2",ecc]}).

can we have any idea or solution for this error?

0

1 Answer 1

1

The reason is because the returned callback does not match the requested one.

Angular2 is expecting the __ng_jsonp__.__req0.finished it passed in callback param in request.

But instead the _todayMatchesCallback is returned. You must either modify the middleware/backend to respect the callback param.

Sign up to request clarification or add additional context in comments.

2 Comments

i call this URL localhost:4000/matches?callback=JSONP_CALLBACK, i must change the middleware for return callback instead _todayMatchesCallback ?
That's correct. You need to return callback passed as parameter instead of the _todayMatchesCallback. Also since you're new, if the answer is correct please remember to upvote it and accept :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.