0

I don't know how to pass the --user field of this curl request in vue-apollo

curl -v \
  --user 'user@domain.com:password' \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{ "query": "{ companies{ uid name url }}" }' \
  http://localhost:4000/graphql

where in vue-apollo can I set --user ?

I've tried in vue-apollo options object the following

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`
};

but it doesn't work

I'm expecting the companies results

{
    "data": {
        "companies": [
            {
                "id": "someId",
                "name": "Facebook",
                "url": "facebook.com"
            },
            {
                "id": "someId",
                "name": "Twitter",
                "url": "twitter.com"
            }
        ]
    }
}

1 Answers1

0

The getAuth method in defaultOptions should return the encoded Basic authentication

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==`
};