私はreactjs
アプリケーションとredux-thunk
ミドルウェアでisomorphic-fetch
を使用しようとしました。しかし、私は、サーバーが{"user": "happy tree friends"}
のようなものを返す場合でも`isomorphic-fetch` response.json()メソッドは常にスローします。予期しない入力エラーの終了
let config = {
method: 'POST',
headers: { 'Content-Type':'application/x-www-form-urlencoded' },
mode: 'no-cors',
body: "username=foo&password=bar"
};
fetch('my_url', config)
.then(response => {
response.json().then(user => ({user, response})) // here is where the error always been thrown
})
を行うときに、それらのUnexpected end of input error
を得続けます。 このモジュールを使用している方法が間違っていたり、サーバーが間違ったJSONデータを返すだけです。
ヘルプ!!!