需要修復fetch函數調用。 fetch('https://toyshelf-api.herokuapp.com/api/auth/register', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ username: this.state.username, email: this.state.email, password: this.state.password })}).then(response => console.log(Json.parse(response))).catch(error => console.log(error));// fetch function call signature should be like this as it is asynchronousfetch(url, options).then(response => {}); 注意,這假設服務器返回的response是Json字符串,可以是parsed,否則會出現運行時錯誤。請參閱MDN json解析文檔。