Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hit the search API #93

Merged
merged 1 commit into from
Mar 10, 2016
Merged

Hit the search API #93

merged 1 commit into from
Mar 10, 2016

Conversation

mstriemer
Copy link
Contributor

This adds normalizr for helping with API responses. Fixes mozilla/addons#5618.

search-api mov

@mstriemer
Copy link
Contributor Author

I haven't tested the isomorphic stuff and the API needs better test coverage. Wanted to get the PR up though.

@mstriemer mstriemer changed the title Hit the search API [WIP] Hit the search API Mar 8, 2016
@mstriemer mstriemer changed the title [WIP] Hit the search API Hit the search API Mar 9, 2016
@mstriemer
Copy link
Contributor Author

This is ready for review. I'm going to make this universal in mozilla/addons#5660.

import { Schema, arrayOf, normalize } from 'normalizr';

// FIXME: Load this from something.
const API_HOST = 'https://addons-dev.allizom.org';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed https://github.com/mozilla/addons-frontend/issues/105 to support client-side configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you load this in via config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was giving me undefined. That file uses process.env throughout so I don't know how it would work in the browser.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right - duh - ok we should deal with that separately with a flag instead e.g: https://github.com/erikras/react-redux-universal-hot-example/blob/master/webpack/dev.config.js#L107

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So config.get('env') is "production" in the browser (through karma anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried getting this to work but it didn't work on the first try and I'm not sure if we'll just need process.env.NODE_ENV or more than that so I'm going to leave it for the other issue.

@mstriemer mstriemer force-pushed the search-api-23 branch 2 times, most recently from 06fa034 to 97e08dc Compare March 9, 2016 22:19
.withArgs({query: 'Yahoo!', entities: {addons: {foo: {}, bar: {}}}, result: ['foo', 'bar']})
.once()
.returns(loadAction);
handleSearch('Yahoo!', response).then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this returns a promise if you just simply return it you won't need to use done and failure should get handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, I had tried that originally but I must not have been returning the promise from my helper function so it just blew up. That's much cleaner.

@muffinresearch
Copy link
Contributor

r+wc

@mstriemer mstriemer force-pushed the search-api-23 branch 2 times, most recently from 30197d4 to fa130e4 Compare March 10, 2016 19:45
const addon = new Schema('addons', {idAttribute: 'slug'});

function makeQueryString(opts) {
// FIXME: This should use a real query string generator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This adds normalizr for helping with API responses.
mstriemer added a commit that referenced this pull request Mar 10, 2016
@mstriemer mstriemer merged commit b203cb0 into mozilla:master Mar 10, 2016
@mstriemer mstriemer deleted the search-api-23 branch March 10, 2016 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants