fix: properly change host via db.host method

This commit is contained in:
thecodrr
2020-09-19 11:46:36 +05:00
parent 1058ae9909
commit bf29a0ab16
5 changed files with 32 additions and 19 deletions

View File

@@ -25,7 +25,7 @@
* Syncing should pause until all the conflicts have been resolved
* And then it should continue.
*/
import { HOST, HEADERS } from "../../utils/constants";
import Constants from "../../utils/constants";
import Collector from "./collector";
import Merger from "./merger";
import { areAllEmpty } from "./utils";
@@ -46,8 +46,8 @@ export default class Sync {
}
async _fetch(lastSynced, token) {
let response = await fetch(`${HOST}/sync?lst=${lastSynced}`, {
headers: { ...HEADERS, Authorization: `Bearer ${token}` },
let response = await fetch(`${Constants.HOST}/sync?lst=${lastSynced}`, {
headers: { ...Constants.HEADERS, Authorization: `Bearer ${token}` },
});
return await response.json();
}
@@ -108,9 +108,9 @@ export default class Sync {
}
async _send(data, token) {
let response = await fetch(`${HOST}/sync`, {
let response = await fetch(`${Constants.HOST}/sync`, {
method: "POST",
headers: { ...HEADERS, Authorization: `Bearer ${token}` },
headers: { ...Constants.HEADERS, Authorization: `Bearer ${token}` },
body: JSON.stringify(data),
});
if (response.ok) {