我正在尝试将简单的graphql
查询传递给我的http.get
。这里有两个问题:id不接受empID,请求失败。请指教
以下是代码:
EmployeeService.prototype.getEmployee = function(empID) {
let deferred = ij.q.defer();
// Get the endpoint.
const myQuery = `{
employee(id: {empID}) {
id
items {
nodes {
id
name
}
}
}
}`;
const gql = 'graphql';
const queryURL = `${gql}?query=${encodeURI(myQuery)}`;
$http.get(queryURL).then((response) => {
let result = response && response.data;
if (result) {
deferred.resolve(result);
}
}, (reason) => {
});
return deferred.promise;
};