File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " dafolio" ,
3- "version" : " 0.2.4 " ,
3+ "version" : " 0.2.5 " ,
44 "private" : true ,
55 "dependencies" : {
66 "@testing-library/jest-dom" : " ^5.16.5" ,
Original file line number Diff line number Diff line change @@ -166,19 +166,54 @@ export const Map = () => {
166166 }
167167 } ;
168168
169+ const postLocationData = async ( data ) => {
170+ try {
171+ const response = await axios . post (
172+ `${ process . env . REACT_APP_API_BASE_URL } /locations` ,
173+ data ,
174+ {
175+ headers : {
176+ "Content-Type" : "application/json" ,
177+ } ,
178+ }
179+ ) ;
180+
181+ console . log ( "Location data posted successfully:" , response . data ) ;
182+ } catch ( error ) {
183+ console . error ( "Error posting location data:" , error ) ;
184+ }
185+ } ;
186+
169187 const addUserLocation = ( ) => {
170188 if ( "geolocation" in navigator ) {
171189 navigator . geolocation . getCurrentPosition (
172190 ( position ) => {
173191 const { latitude, longitude } = position . coords ;
174192
193+ const locationData = {
194+ ip : "0.0.0.0" ,
195+ continent_code : null ,
196+ continent_name : null ,
197+ country_code2 : null ,
198+ country_code3 : null ,
199+ country_name : null ,
200+ city : null ,
201+ zipcode : null ,
202+ latitude,
203+ longitude,
204+ isp : null ,
205+ } ;
206+
207+ console . log ( "User location data:" , locationData ) ;
175208 map . current . loadImage ( "/pointer.png" , ( error , image ) => {
176209 if ( error ) throw error ;
177210 if ( ! map . current . hasImage ( "user-location" ) ) {
178211 map . current . addImage ( "user-location" , image ) ;
179212 }
180213 updateUserLocation ( longitude , latitude ) ;
181214 } ) ;
215+
216+ postLocationData ( locationData ) ;
182217 } ,
183218 ( error ) => {
184219 console . error ( "Error getting location:" , error ) ;
You can’t perform that action at this time.
0 commit comments