🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@foursquare/foursquare-places

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foursquare/foursquare-places

This is a javascript wrapper for Foursquare's APIs

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
3
Created
Source

Summary

framework agnostic javascript wrapper for foursquare's APIs

CircleCI

Tests

yarn or npm yarn test

Commit Policy

please test any functions added and put the tests in the /tests folder

React Example

Here is a simple react application:

  • Setup React Project

npx create-react-app mr-jitters

  • Install Package

cd mr-jitters

npm install -i @foursquare/foursquare-places

  • Create ./.env file and add CLIENT_ID and CLIENT_SECRET
REACT_APP_CLIENT_ID=InsertClientId
REACT_APP_CLIENT_SECRET=InsertClientSecret
  • Add Env file to .gitignore
# env
.env
  • Modify your src/App.js
import React, { useState, useEffect } from "react";
import Foursquare from "@foursquare/foursquare-places";

// need to create an .env file - see instructions in link
// https://stackoverflow.com/questions/48699820/how-do-i-hide-api-key-in-create-react-app
const CLIENT_ID = process.env.REACT_APP_CLIENT_ID;
const CLIENT_SECRET = process.env.REACT_APP_CLIENT_SECRET;
const foursquare = new Foursquare(CLIENT_ID, CLIENT_SECRET);

const App = () => {
  const [items, setItems] = useState([]);
  const [params, setParams] = useState({
    ll: "37.7749,-122.4194",
    query: "Blue Bottle"
  });

  useEffect(() => {
    foursquare.venues.getVenues(params).then(res => {
      setItems(res.response.venues);
    });
  }, [params]);

  return (
    <div>
      <div>Items:</div>
      {items.map(({ id, name }) => (
        <div key={id}>{name}</div>
      ))}
    </div>
  );
};

export default App;
  • Start your React App

npm start

Keywords

react-component

FAQs

Package last updated on 04 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts