0
graphql
データを取得するのにapollo-fetch
を使用しています。 スクリプトエラーで終了していますが、リクエストが通過しません。このようなかなり簡単な要求で何がうまくいかないのか分かりません。助けてください。ここで単純なgarphqlクエリでapollo-fetchがネットワークエラーで終了する
Uncaught (in promise) Error: Network request failed to return valid JSON
at throwHttpError (apollo-fetch.js:41)
at apollo-fetch.js:141
at <anonymous>
throwHttpError @ apollo-fetch.js:41
(anonymous) @ apollo-fetch.js:141
Promise rejected (async)
をコードです:
はここでエラーです
const { createApolloFetch } = require('apollo-fetch');
PlayService.prototype.getPlays = function(playID) {
const fetch = createApolloFetch({
uri: 'graphql'
});
const playQuery = `query ($playid: String) {
plays(id: $playid) {
id
items {
nodes {
id
name
}
}
}
}`;
fetch({
query: playQuery,
variables: { playid: playID }
}).then((res) => {
console.log(res.data);
});
};