Axios See Plain Headers Code Example
Example 1: pass header in axios
const headers = { 'Content-Type': 'application/json', 'Authorization': 'JWT fefege...' } axios.post(Helper.getUserAPI(), data, { headers: headers }) .then((response) => { dispatch({ type: FOUND_USER, data: response.data[0] }) }) .catch((error) => { dispatch({ type: ERROR_FINDING_USER }) })
Example 2: axios defaults headers common
var instance = axios.create({ baseURL: 'https://some-domain.com/api/', timeout: 1000, headers: {'X-Custom-Header': 'foobar'} });
Comments
Post a Comment