populating start page with results
freedomtrain opened this issue · comments
This is what I have in my Container.js file …..Can you let me know if this is correct to have Jimi Hendrix search results populate the start page ?
import React, { Component } from 'react';
import List from './List';
import Message from './Message';
import emitter from '../emitter';
import reqwest from 'reqwest';
import { getMedia } from '../utils';
class Container extends Component {
state = {
type: 'start'
};
componentDidMount = () => {
// first search
this.search({ query: 'jimi hendrix' });
emitter.on('search', (state) => {
this.setState({ type: 'loading' });
this.search(state);
});
};
search = ({ query, media = 'all' }) => {
reqwest({
url: https://itunes.apple.com/search?media=${getMedia(media || 'all')}&term=${query.split(' ').join('+')}
,
type: 'jsonp'
})
.then(response => this.setState({ response, type: response.resultCount || 'noContent' }))
.fail(err => this.setState({ type: 'error' }));
componentWillUnmount = () => {
emitter.removeListener('search');
};
looks fine to me
To have the changes work do i need to stop and start node ?
On May 9, 2016 at 1:59:25 PM, Leo Hsieh (notifications@github.com) wrote:
looks fine to me
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
I have everything working !!!!!
Thanks for all of you help
On May 9, 2016 at 1:59:25 PM, Leo Hsieh (notifications@github.com) wrote:
looks fine to me
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub