redux observable - RxJs How to set default request headers? -


not sure there way set default request headers in rxjs axios js as-

axios.defaults.headers.common['authorization'] = 'c7b9392955ce63b38cf0901b7e523efbf7613001526117c79376122b7be2a9519d49c5ff5de1e217db93beae2f2033e9'; 

here epic code want set request headers -

export default function epicfetchproducts(action$, store) {     return action$.oftype(fetch_products_request)     .mergemap(action =>         ajax.get(`http://localhost/products?${action.q}`)       .map(response => dofetchproductsfulfilled(response))     ); } 

please help.

it's not possible set default headers ajax requests using rxjs's ajax utilities.

you can provide headers in each call, or create own simple wrapper provides them default.

utils/ajax.js

const defaultheaders = {   authorization: 'c7b9392955ce63b38cf090...etc' };  export const = (url, headers) =>   ajax.get(url, object.assign({}, defaultheaders, headers)); 

my-example.js

import * ajax './utils/ajax';  // usage same, defaults ajax.get(`http://localhost/products?${action.q}`;) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -