34 | export function Put(url: string, data: any = {}, json: boolean = true, contentType: string = 'application/json') { |
35 | let token = ReadCookie('XSRF-TOKEN'); |
36 | |
37 | let myInit: RequestInit = { |
38 | method: 'PUT', |
39 | credentials: 'same-origin', |
40 | headers: !!contentType ? { |
41 | 'Content-Type': contentType, |
42 | 'X-XSRF-TOKEN': token |
43 | } : { |
44 | 'X-XSRF-TOKEN': token |
45 | }, |
46 | body: json ? JSON.stringify(data) : data, |
47 | mode: 'cors', |
48 | cache: 'default' |
49 | }; |
50 | |
51 | let myRequest = new Request(url); |
52 | |
53 | return fetch(myRequest, myInit); |
54 | } |