我不知道如何在vue-apollo中传递这个curl请求的--user字段
curl -v \
--user 'user@domain.com:password' \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "{ companies{ uid name url }}" }' \
http://localhost:4000/graphql我可以在vue-apollo的什么地方设置--user?
我在vue-apollo选项对象中尝试了以下内容
const defaultOptions = {
// You can use `https` for secure connection (recommended in production)
httpEndpoint,
wsEndpoint: null,
persisting: false,
websocketsOnly: false,
ssr: false,
getAuth: () => `Basic user@domain.com:password`
};但它不起作用
我期待着公司的业绩
{
"data": {
"companies": [
{
"id": "someId",
"name": "Facebook",
"url": "facebook.com"
},
{
"id": "someId",
"name": "Twitter",
"url": "twitter.com"
}
]
}
}发布于 2019-05-21 12:36:41
defaultOptions中的getAuth方法应返回编码的基本身份验证
getAuth: () => `Basic ZrT2mWt3gJKHRJ33tf20hJrq==`const defaultOptions = {
// You can use `https` for secure connection (recommended in production)
httpEndpoint,
wsEndpoint: null,
persisting: false,
websocketsOnly: false,
ssr: false,
getAuth: () => `Basic ZrT2mWt3gJKHRJ33tf20hJrq==`
};https://stackoverflow.com/questions/56230929
复制相似问题