Last active
          November 22, 2018 20:23 
        
      - 
      
- 
        Save bfunc/ac6d7455e99137852525a6bde148abe9 to your computer and use it in GitHub Desktop. 
    http request window.fetch() snippet with application/json headers
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fetch('http://HOST/api', | |
| { | |
| method: 'post', // 'put' | |
| headers: { 'Accept': 'application/json, text/plain', 'Content-Type': 'application/json' }, | |
| body: JSON.stringify( {"User_employee_id":"1","template_id":0,"data":[{"id":1509003681672,"contract":"EuroDollar@SEP18"}]} ), | |
| // cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached | |
| // credentials: 'same-origin', // include, same-origin, *omit | |
| // mode: 'cors', // no-cors, cors, *same-origin | |
| // redirect: 'follow', // manual, *follow, error | |
| // referrer: 'no-referrer', // *client, no-referrer | |
| }) | |
| .then(response => response.json()) | |
| .then(console.log) | |
| .catch(console.warn); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment