Setting up for Twitter client

This commit is contained in:
Rodrigo Pedroso 2019-06-20 12:17:41 -04:00
commit 9989d0a5ba
3 changed files with 38 additions and 5 deletions

View file

@ -5,18 +5,22 @@ import Post from './Posts'
const App = () => ( const App = () => (
<div className = 'row mt-5'> <div className = 'row mt-5'>
<div className = 'col-md-4 offset-md-1'>
<h2>Articles</h2> <div className = 'col-md-4 offset-md-1'>
<h2>Articles</h2>
<List /> <List />
</div> </div>
<div className = 'col-md-4 offset-md-1'> <div className = 'col-md-4 offset-md-1'>
<h2>Add a new article</h2> <h2>Add a new article</h2>
<Form /> <Form />
</div> </div>
<div className="col-md-4 offset-md-1"> <div className="col-md-4 offset-md-1">
<h2>API posts</h2> <h2>API posts</h2>
<Post /> <Post />
</div> </div>
</div> </div>
) )

View file

@ -5,9 +5,7 @@ const forbiddenWords = ["spam", "money"]
export function forbiddenWordsMiddleware({ dispatch }) { export function forbiddenWordsMiddleware({ dispatch }) {
return function(next) { return function(next) {
return function(action) { return function(action) {
// do your stuff
if (action.type === ADD_ARTICLE) { if (action.type === ADD_ARTICLE) {
const foundWord = forbiddenWords.filter(word => const foundWord = forbiddenWords.filter(word =>
action.payload.title.includes(word) action.payload.title.includes(word)
) )

View file

@ -14,6 +14,37 @@ function* workerSaga() {
} }
function getData() { function getData() {
// const token = 'token'
// let myHeaders = new Headers({
// 'Content-Type': 'text/plain',
// 'Content-Length': content.length.toString(),
// 'X-Custom-Header': 'ProcessThisImmediately',
// Authorization: `OAuth ${token}`
// })
// let heads = {
// authorization: 'OAuth oauth_consumer_key="consumer-key-for-app"',
// oauth_nonce="generated-nonce",
// oauth_signature="generated-signature",
// oauth_signature_method="HMAC-SHA1",
// oauth_timestamp="generated-timestamp",
// oauth_token="access-token-for-authed-user",
// oauth_version="1.0"
// }
// let config = {
// method: 'GET',
// headers: myHeaders,
// }
// let url = 'https://api.twitter.com/1.1/search/tweets.json?q=from%3Atwitterdev&result_type=mixed&count=2'
// return fetch(url, config).then(response => {
// console.log(response)
// response.json()
// })
return fetch("https://jsonplaceholder.typicode.com/posts").then(response => return fetch("https://jsonplaceholder.typicode.com/posts").then(response =>
response.json() response.json()
) )