I am trying to pull nearby venues from foursquare API using react native.
For beginning i tried to pull venues from some specified coordinates and here is my very simple code;
import React from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import axios from 'axios'
export default function App() {
var venues;
return (
<View style={styles.container}>
<Text>{this.venues} qwewqe</Text>
<Button
onPress={() => {
this.getVenues()
}}
title="GET VENUES"
/>
</View>
);
}
getVenues = () => {
const endpoint = 'https://api.foursquare.com/v2/venues/explore'
const parameters = {
CLIENT_ID:"*******",
CLIENT_SECRET:"*******",
section: "food",
ll: " 40.74224,-73.99386",
v: "20190909"
}
axios.get(endpoint + new URLSearchParams(parameters))
.then(response => {
console.log(response)
this.venues = response;
return response;
})
.catch(error => {
console.log("ERROR >> " + error)
})
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Console output:
ERROR >> Request failed with error code 400
Well, 400 is as you know is bad request. so code looks working for some point.
I did not understand what is wrong with my request ? also checked the docs but didnt. For error details i ran on browser but i am getting getVenues is not a function error.
Thanks for your support...