Tôi đang cố gắng đăng biểu mẫu chứa first_name, last_name, email, mật khẩu và password_confirmation bằng cách sử dụng api tìm nạp phản ứng gốc.Làm cách nào để đăng biểu mẫu bằng cách tìm nạp trong phản hồi gốc?
fetch('http://localhost:3000/auth', {
method: 'post',
body: JSON.stringify({
config_name: 'default',
first_name: this.state.first_name,
last_name: this.state.last_name,
email: this.state.email,
password: this.state.password,
password_confirmation: this.state.password_confirmation,
})
})
Output trong Rails console
Parameters: {"{\"config_name\":\"default\",\"first_name\":\"Piyush\",\"last_name\":\"Chauhan\",\"email\":\"[email protected]\",\"password\":\"diehard4\",\"password_confirmation\":\"diehard4\"}"=>"[FILTERED]"}
Unpermitted parameter: {"config_name":"default","first_name":"Piyush","last_name":"Chauhan","email":"[email protected]","password":"diehard4","password_confirmation":"diehard4"}
Vì vậy, đăng toàn bộ giá trị của nó như là chuỗi và đường ray được phân tích các chuỗi như là một biến. Tôi muốn loại bỏ "{" khỏi phản hồi json. Làm thế nào để làm nó ?
Vui lòng cung cấp chi tiết và giải thích thêm – M98