TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Rai
1.6k
149
11k
Data not able to fetch from webservice in Angular
Feb 3 2020 4:28 AM
I am trying to fetch data from webservice but not able to do.
My code is:-
login(){
console.log(
"Username:"
+
this
.username);
console.log(
"Password:"
+
this
.password);
var url =
'https://localhost:5125/WebService1.asmx'
+
'/HelloWorld'
;
let data1 =
this
.http.
get
(url);
data1.subscribe(data =>{
console.log(
'hello'
);
this
.result = data;
this
.navCtrl.push(RegisterPage,{text:
this
.password});
});
}
and my webservice code is:-
public
int
HelloWorld()
{
return
5;
}
I am getting error:-
core.js:1449ERROR
HttpErrorResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: "http://localhost:5125/WebService1.asmx/HelloWorld", ok: false, …}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
status: 200
statusText: "OK"
url: "http://localhost:5125/WebService1.asmx/HelloWorld"
ok: false
name: "HttpErrorResponse"
message: "Http failure during parsing for http://localhost:5125/WebService1.asmx/HelloWorld"
error:
error: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at XMLHttpRequest.onLoad (http://localhost:8100/build/vendor.js:79401:51) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581) at r.runTask (http://localhost:8100/build/polyfills.js:3:10834) at e.invokeTask [as invoke] (http://localhost:8100/build/polyfills.js:3:16794) at p (http://localhost:8100/build/polyfills.js:2:27648) at XMLHttpRequest.v (http://localhost:8100/build/polyfills.js:2:27893)
stack: "SyntaxError: Unexpected token < in JSON at position 0↵ at JSON.parse (<anonymous>)↵ at XMLHttpRequest.onLoad (http://localhost:8100/build/vendor.js:79401:51)↵ at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)↵ at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33)↵ at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581)↵ at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)↵ at e.invokeTask [as invoke] (http://localhost:8100/build/polyfills.js:3:16794)↵ at p (http://localhost:8100/build/polyfills.js:2:27648)↵ at XMLHttpRequest.v (http://localhost:8100/build/polyfills.js:2:27893)"
message: "Unexpected token < in JSON at position 0"
Reply
Answers (
2
)
Question about Angular 6 chart Mdbootstrap
Page Source HTML After AngularJs Templating