Testes com api externa

This commit is contained in:
Hugo Falcao
2022-05-15 23:12:48 -03:00
parent 6b7ebe046a
commit e654b6a6b0
6 changed files with 192 additions and 206 deletions

View File

@@ -1,4 +1,5 @@
import instance from '../services/api';
import { setStore } from "../store/RecordsStore";
// import LocalStorage from '../LocalStorage';
// let token:string;
@@ -42,4 +43,14 @@ export async function create(CadastroRequest: any) {
const response = await instance.post("http://localhost:3333/users/", CadastroRequest);
return response.data;
}
export async function getUsersSearching(currentPoint: any) {
// Replace lat/long with values from get current location.
// Allow choosing of radius?
// Offset could = amount loaded in an infinite scroll?
var latitude = currentPoint.latitude, longitude = currentPoint.longitude, radius = 5000, offset = 0;
const response = await fetch(`http://localhost:4000/get-records?latitude=${ latitude }&longitude=${ longitude }&radius=${ radius }&offset=${ offset }`);
const data = await response.json();
setStore(data);
}