Y
Y
yeszhanov2019-03-17 12:35:45
PHP
yeszhanov, 2019-03-17 12:35:45

New user registration by api, React and PHP?

Guys, good afternoon everyone. There is a problem, you need to register a new user using axios by api. You need to send data to the server. There is a screenshot of how this is done on the backend, but I can’t implement it on React. As I understand it, there are links user/create, company/create, company/add-user. How to insert these links in a query?
screenshot:
5c8e14819697d862932890.jpeg
my code may have missed some fields.
signUp(event) {
event.preventDefault()
const formdata = new FormData()
formdata.append("username", this.state.userRegistration.email)
formdata.append("password", this.state.userRegistration.password)
formdata .append("name", this.state.userRegistration.name)
formdata.append("companyName", this.state.userRegistration.companyName)
formdata.append("region", this.state.userRegistration.selectedValue)
axios
.post(" http://dev.******* ***********.com ", formdata)
.then(res => {
if (res.data) {
console.log("success")
this.props.history.push("/settings ")
}
})
.catch(error => {
console.log(error)
})
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
keslo, 2019-03-18
@keslo

You basically have three requests:
The third request is obtained from the data of the first two. Thus, you need to pass the fields in POST:
You pass all this in one request, and then the backend will figure it out :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question