Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async post(path: string, body = {}) {
const options = {
body: json(body),
headers: this.setHeaders(),
method: 'POST',
};
try {
const response = await this.http.fetch(`${config.apiUrl}${path}`, options);
return await status(response);
} catch (error) {
try {
return await parseError(error);
} catch {
return undefined;
}
}
}
public async put(path: string, body = {}) {
const options = {
body: json(body),
headers: this.setHeaders(),
method: 'PUT',
};
try {
const response = await this.http.fetch(`${config.apiUrl}${path}`, options);
return await status(response);
} catch (error) {
try {
return await parseError(error);
} catch {
return undefined;
}
}
}