Skip to content

Commit 852d649

Browse files
inline mocks.json for dev (#410)
1 parent 7b2b37b commit 852d649

File tree

3 files changed

+492
-8
lines changed

3 files changed

+492
-8
lines changed

dev/App.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,21 @@ class App extends Component {
3939
}
4040

4141
componentWillMount() {
42-
fetch(
43-
'https://api.github.com/repos/plotly/plotly.js/contents/test/image/mocks'
44-
)
42+
// curl https://api.github.com/repos/plotly/plotly.js/contents/test/image/mocks \
43+
// | jq '[.[] | .name ]' > mocks.json
44+
fetch('/mocks.json')
4545
.then(response => response.json())
4646
.then(mocks => this.setState({mocks}));
4747
}
4848

4949
loadMock(mockIndex) {
50-
const mock = this.state.mocks[mockIndex];
51-
fetch(mock.url, {
52-
headers: new Headers({Accept: 'application/vnd.github.v3.raw'}),
53-
})
50+
fetch(
51+
'https://api.github.com/repos/plotly/plotly.js/contents/test/image/mocks/' +
52+
this.state.mocks[mockIndex],
53+
{
54+
headers: new Headers({Accept: 'application/vnd.github.v3.raw'}),
55+
}
56+
)
5457
.then(response => response.json())
5558
.then(figure => {
5659
this.setState({

dev/Nav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Nav = props => (
1212
value={props.currentMockIndex}
1313
name="mock-dropdown"
1414
options={props.mocks.map((item, i) => ({
15-
label: item.name,
15+
label: item,
1616
value: i,
1717
}))}
1818
className="open-top"

0 commit comments

Comments
 (0)