This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configureStore from 'redux-mock-store'; | |
import promiseMiddleware from 'redux-promise-middleware'; | |
import moxios from 'moxios'; | |
import * as actions from '../../actions'; | |
import instance from '../../config/axiosconfig'; | |
describe('async actions', () => { | |
const middlewares = [promiseMiddleware()]; | |
const mockStore = configureMockStore(middlewares); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// storeconfig.js | |
import { createStore, applyMiddleware } from 'redux'; | |
import { logger } from 'redux-logger'; | |
import promiseMiddleware from 'redux-promise-middleware'; | |
import reducers from '../reducers'; | |
const middleware = applyMiddleware(promiseMiddleware(), logger); | |
const store = createStore(reducers, middleware); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// axiosconfig.js | |
import axios from 'axios'; | |
import store from './store'; | |
// configure base url | |
const instance = axios.create({ | |
baseURL: 'http://localhost:5000', | |
}); | |
// intercept requests and add authorization token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getBucketLists = () => { | |
return (dispatch) => { | |
dispatch({type: "GET_BUCKETLISTS"}); | |
instance.get('/bucketlists') | |
.then((response) => { | |
dispatch({type: "GET_BUCKETLISTS_FULFILLED", payload: response.data}); | |
}) | |
.catch((err) => { | |
dispatch({type: "GET_BUCKETLISTS_REJECTED", payload: err }}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getBucketLists = () => ({ | |
type: 'GET_BUCKETLISTS', | |
payload: instance.get('/bucketlists'), | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"username": "Batman", | |
"firstname": "Bruce", | |
"lastname": "Wayne", | |
"DOB": "2/10/1983", | |
"email":"batman@gotham.dc", | |
"friends": ["Wonder woman", "Flash", "James Gordon" ], | |
"status": "Single and violently searching", | |
"villains":["Joker", "Bane", "Penguin"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
users { | |
name | |
friends { | |
name | |
villains{ | |
name | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"user": { | |
"name": "Batman", | |
"friends": [ | |
{ | |
"name": "Wonder woman", | |
"villains": [{"name": "Aries"}] | |
}, | |
{ | |
"name": "Flash", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axios.get('http://localhost:8000/users/1/friends') | |
.then(response => console.log(response.data)) | |
.catch(err => console.log(err)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Schema = [ | |
` | |
type Team { | |
id: Int! | |
profile:String! | |
name:String! | |
users: [User] | |
} | |
type Address { | |
streetAddress:String! |
OlderNewer