- Service Worker: Save on IndexDb and Sync to send after to the DB.
- Insert record on MongoDb, POST, GET.
This commit is contained in:
@@ -5,14 +5,27 @@ async function sendRequest (url: string, lang: string, mytok: string, method: st
|
||||
// let mytok: string = this.getTok()
|
||||
const authHeader = new Headers()
|
||||
|
||||
console.log('sendRequest:', url)
|
||||
|
||||
authHeader.append('content-type', 'application/json')
|
||||
authHeader.append('x-auth', mytok)
|
||||
authHeader.append('accept-language', lang)
|
||||
const configInit: RequestInit = {
|
||||
method: method,
|
||||
cache: 'no-cache',
|
||||
body: JSON.stringify(mydata),
|
||||
headers: authHeader
|
||||
|
||||
let configInit: RequestInit
|
||||
|
||||
if (method === 'GET') {
|
||||
configInit = {
|
||||
method: method,
|
||||
cache: 'no-cache',
|
||||
headers: authHeader
|
||||
}
|
||||
} else {
|
||||
configInit = {
|
||||
method: method,
|
||||
cache: 'no-cache',
|
||||
body: JSON.stringify(mydata),
|
||||
headers: authHeader
|
||||
}
|
||||
}
|
||||
|
||||
const request: Promise<Response> = fetch(url, configInit)
|
||||
|
||||
Reference in New Issue
Block a user