MCPcopy Create free account
hub / github.com/crazycodeboy/GitHubPopular / loadData

Function loadData

js/page/SearchPage.js:132–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 }
131
132 loadData() {
133 this.updateState({
134 isLoading: true,
135 showBottomButton: false,
136 });
137 this.cancelable = makeCancelable(fetch(this.genFetchUrl(this.state.inputKey)));
138 this.cancelable.promise
139 .then((response)=>response.json())
140 .then((responseData)=> {
141 if (!this || !responseData || !responseData.items || responseData.items.length === 0) {
142 this.refs.toast.show(this.state.inputKey + ' nothing found.', DURATION.LENGTH_SHORT);
143 this.updateState({isLoading: false, rightButtonText: 'Go',});
144 return;
145 }
146 this.items = responseData.items;
147 this.getFavoriteKeys();
148 if (!this.checkKeyIsExist(this.keys, this.state.inputKey)) {
149 this.updateState({showBottomButton: true,})
150 }
151 })
152 .catch((error)=> {
153 this.updateState({
154 isLoading: false,
155 rightButtonText: 'Go',
156 });
157 });
158 }
159
160 updateFavorite() {
161 this.getFavoriteKeys();

Callers

nothing calls this directly

Calls 3

makeCancelableFunction · 0.85
getFavoriteKeysMethod · 0.80
updateStateMethod · 0.45

Tested by

no test coverage detected