Closing many tickets
This commit is contained in:
@@ -2,7 +2,7 @@ import EventEmitter from "eventemitter3"
|
||||
import io from "socket.io-client"
|
||||
import { AsyncStorage } from "react-native"
|
||||
import autobind from "autobind-decorator"
|
||||
import { localIPAddr } from "./config"
|
||||
import { config } from "./config"
|
||||
|
||||
const authTokenKeyName = "AuthToken"
|
||||
const backendKeyName = "Backend"
|
||||
@@ -37,7 +37,7 @@ class API extends EventEmitter {
|
||||
static urls = {
|
||||
normal: "https://dar.kss.us.com/api",
|
||||
test: "https://dar-test.kss.us.com/api",
|
||||
local: `http://${localIPAddr || "localhost"}:3001`,
|
||||
local: `http://${config.localIPAddr || "localhost"}:3001`,
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -384,6 +384,45 @@ class API extends EventEmitter {
|
||||
return this.delete("/activities/" + _id)
|
||||
}
|
||||
|
||||
getAddress(coord) {
|
||||
var promise = new Promise((resolve, reject) => {
|
||||
let fetchOptions = {
|
||||
method: "GET",
|
||||
mode: "no-cors",
|
||||
}
|
||||
|
||||
fetch(
|
||||
config.googleGeocodeURL +
|
||||
`?latlng=${coord.latitude},${coord.longitude}&key=${
|
||||
config.googleAPIKey
|
||||
}`,
|
||||
fetchOptions
|
||||
)
|
||||
.then((res) => {
|
||||
return Promise.all([Promise.resolve(res), res.json()])
|
||||
})
|
||||
.then((arr) => {
|
||||
let [res, responseBody] = arr
|
||||
|
||||
if (res.ok) {
|
||||
let address = ""
|
||||
|
||||
if (responseBody.results && responseBody.result.length > 0) {
|
||||
address = responseBody.results[0].formatted_address
|
||||
}
|
||||
|
||||
resolve(address)
|
||||
} else {
|
||||
reject(new APIError(res.status, responseBody.message))
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(new NetworkError(error.message))
|
||||
})
|
||||
})
|
||||
return promise
|
||||
}
|
||||
|
||||
upload(file, progressCallback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunkSize = 32 * 1024
|
||||
|
||||
Reference in New Issue
Block a user