However I am getting an error in my console when making the GET request.
Is there any easy way to access the twitter API when using local host during development? I am only doing front end work at the moment.
Error:
Failed to load https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=nimaiwalsh: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 400. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
What you’re doing is trying to use the user based authentication in your front end code. You’ll want to use the application-only request as documented here. The pattern you’re using there is for server-side logins.
Calling twitter API from the front end is not a normal practice because you need to expose your secret credentials, twitter dont send the Access-Control-Allow-Origin in their response headers so a solution could be disabling the browser security, in chrome for linux is done opening chrome from terminal with a flag and passing a directory wich chrome session will use to store data.
google-chrome-stable --disable-web-security --user-data-dir=data