Skip to content

Commit

Permalink
Build.
Browse files Browse the repository at this point in the history
  • Loading branch information
elvishp2006 committed May 17, 2019
1 parent 125f29f commit 2224d0c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
17 changes: 10 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module.exports = {
"env": {
"browser": true
env: {
browser: true,
},
"extends": "airbnb",
"rules":{
extends: 'airbnb',
rules: {
// Prevent warnings for webpack resolve aliases.
"import/no-unresolved": "off",
'import/no-unresolved': 'off',
// Prevent warnings for webpack extension resolution.
"import/extensions": "off"
}
'import/extensions': 'off',
},
globals: {
wpApiSettings: false,
},
};
2 changes: 1 addition & 1 deletion assets/js/bundle.js

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions assets/js/components/field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ export const enhance = compose(
},

loadOptions: ({ field, setSelected }) => (inputValue) => {
const headers = new Headers({
'Content-Type': 'application/json',
'X-WP-Nonce': wpApiSettings.nonce,
credentials: 'same-origin',
});

if (field.value && !inputValue) {
const headers = new Headers({
'Content-Type': 'application/json',
'X-WP-Nonce': wpApiSettings.nonce,
'credentials': 'same-origin'
});
return fetch(`${field.endpoint}/${field.value}`, { headers: headers })
return fetch(`${field.endpoint}/${field.value}`, { headers })
.then(response => response.json())
.then((data) => {
const option = {
Expand Down Expand Up @@ -103,7 +104,7 @@ export const enhance = compose(

params[field.endpoint_search_param] = inputValue;

return fetch(`${field.endpoint}/?${$.param(params)}`,{ headers: headers })
return fetch(`${field.endpoint}/?${$.param(params)}`, { headers })
.then(response => response.json())
.then(json => json.map(data => ({
value: resolve(field.endpoint_value_path, data),
Expand Down

0 comments on commit 2224d0c

Please sign in to comment.