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
osyris zosar
NA
289
27k
Fetich ReactJS with Asp net core
Apr 30 2021 8:38 PM
I am trying to understand fetching in Reactjs
I simply want to pass a string value to my React project
Please help me out
Controller:
namespace
reacttest.Controllers
{
public
class
TestingController : Controller
{
[HttpGet(
"New"
)]
public
string
New()
{
string
Name =
"Jon"
;
return
Name;
}
}
}
ReactJS:
import
{ data } from
'jquery'
;
import
React, { Component } from
'react'
;
export
class
New
extends
Component {
static
displayname = New.name;
constructor(props) {
super
(props);
this
.state = {
Names1 :
"nothing"
};
}
componentDidMount() {
fetch(
'reacttest/TestingController/New'
)
.then(Response => (Response.json())
.then(data => {
this
.setState({ Name1: data }) })
}
render() {
return
(
<h1>my name = {
this
.state.Names1} </h1>
)
}
}
it just returns "Nothing"
Reply
Answers (
1
)
What is the difference between a struct and a class in C#?
Convert html tag to href.