Skip to content

Commit db3a683

Browse files
authored
fix(topbar): provide handleResponse as a component method (#1651)
1 parent b5f4cef commit db3a683

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/standalone/topbar/topbar.jsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default class Topbar extends React.Component {
155155
Accept: "application/json"
156156
})
157157
})
158-
.then(res => handleResponse(res))
158+
.then(res => this.handleResponse(res, { type }))
159159
}
160160

161161
if(type === "client") {
@@ -165,21 +165,20 @@ export default class Topbar extends React.Component {
165165
spec: specSelectors.specJson()
166166
})
167167
})
168-
.then(res => handleResponse(res))
168+
.then(res => this.handleResponse(res, { type }))
169169
}
170+
}
170171

171-
function handleResponse(res) {
172-
if(!res.ok) {
173-
return console.error(res)
174-
}
175-
176-
fetch(res.body.link)
177-
.then(res => res.blob())
178-
.then(res => {
179-
this.downloadFile(res, `${name}-${type}-generated.zip`)
180-
})
172+
handleResponse = (res, { type }) => {
173+
if(!res.ok) {
174+
return console.error(res)
181175
}
182176

177+
fetch(res.body.link)
178+
.then(res => res.blob())
179+
.then(res => {
180+
this.downloadFile(res, `${name}-${type}-generated.zip`)
181+
})
183182
}
184183

185184
clearEditor = () => {
@@ -308,4 +307,4 @@ Topbar.propTypes = {
308307
errSelectors: PropTypes.object.isRequired,
309308
specActions: PropTypes.object.isRequired,
310309
getComponent: PropTypes.func.isRequired
311-
}
310+
}

0 commit comments

Comments
 (0)