Skip to content

Commit b97c179

Browse files
committed
Migrate the frontend to use the new yank API
Signed-off-by: Rustin170506 <[email protected]>
1 parent dd0ebac commit b97c179

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

app/models/version.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,42 @@ export default class Version extends Model {
166166
}
167167

168168
yankTask = keepLatestTask(async () => {
169-
let response = await fetch(`/api/v1/crates/${this.crate.id}/${this.num}/yank`, { method: 'DELETE' });
169+
let response = await fetch(`/api/v1/crates/${this.crate.id}/${this.num}`, {
170+
method: 'PATCH',
171+
headers: {
172+
'Content-Type': 'application/json',
173+
},
174+
body: JSON.stringify({
175+
version: {
176+
yanked: true,
177+
},
178+
}),
179+
});
170180
if (!response.ok) {
171181
throw new Error(`Yank request for ${this.crateName} v${this.num} failed`);
172182
}
173183
this.set('yanked', true);
174184

175-
return await response.text();
185+
return await response.json();
176186
});
177187

178188
unyankTask = keepLatestTask(async () => {
179-
let response = await fetch(`/api/v1/crates/${this.crate.id}/${this.num}/unyank`, { method: 'PUT' });
189+
let response = await fetch(`/api/v1/crates/${this.crate.id}/${this.num}`, {
190+
method: 'PATCH',
191+
headers: {
192+
'Content-Type': 'application/json',
193+
},
194+
body: JSON.stringify({
195+
version: {
196+
yanked: false,
197+
},
198+
}),
199+
});
180200
if (!response.ok) {
181201
throw new Error(`Unyank request for ${this.crateName} v${this.num} failed`);
182202
}
183203
this.set('yanked', false);
184204

185-
return await response.text();
205+
return await response.json();
186206
});
187207
}

0 commit comments

Comments
 (0)