sheaivey / react-axios

Axios Components for React with child function callback
MIT License
180 stars 20 forks source link

how can I send basic auth? #22

Closed jacksonp2008 closed 6 years ago

jacksonp2008 commented 7 years ago

Is there documentation anywhere? I am new to React, trying to add your component in, but have little knowledge of axios.

axios supports basic auth it appears: https://www.npmjs.com/package/axios

// auth indicates that HTTP Basic auth should be used, and supplies credentials. // This will set an Authorization header, overwriting any existing // Authorization custom headers you have set using headers. auth: { username: 'janedoe', password: 's00pers3cret' },

sheaivey commented 6 years ago

Auth can be passed in by the config prop. See the example below...

<Request
  instance={axios.create({})} /* custom instance of axios - optional */
  method="" /* get, delete, head, post, put and patch - required */
  url="" /*  url endpoint to be requested - required */
  data={} /* post data - optional */
  config={auth: {
username: 'janedoe',
password: 's00pers3cret'
}} /* axios config - optional */
  debounce={200} /* minimum time between requests events - optional */
  debounceImmediate={true} /* make the request on the beginning or trailing end of debounce - optional */
  isReady={true} /* can make the axios request - optional */
  onSuccess={(response)=>{}} /* called on success of axios request - optional */
  onLoading={()=>{}} /* called on start of axios request - optional */
  onError=(error)=>{} /* called on error of axios request - optional */
/>