Ver código fonte

fix eslint warnings

Gildas 1 ano atrás
pai
commit
66f48f2bc3
1 arquivos alterados com 11 adições e 11 exclusões
  1. 11 11
      src/lib/rest-form-api/index.js

+ 11 - 11
src/lib/rest-form-api/index.js

@@ -23,7 +23,7 @@
  *   Source.
  */
 
-/* global fetch, btoa, Blob, FileReader, AbortController */
+/* global fetch, Blob, AbortController, File, FormData */
 
 const AUTHORIZATION_HEADER = "Authorization";
 const BEARER_PREFIX_AUTHORIZATION = "Bearer ";
@@ -46,30 +46,30 @@ class RestFormApi {
 	async upload(content, url) {
 
 		this.controller = new AbortController();
-		try{
-			const blob = new Blob([content], { type: 'text/html'})
-			const file = new File([blob], "SingleFile.html", { type: 'text/html' });
+		try {
+			const blob = new Blob([content], { type: "text/html" });
+			const file = new File([blob], "SingleFile.html", { type: "text/html" });
 			let formData = new FormData();
-			if(this.fileFieldName){
-				formData.append(this.fileFieldName, file)
+			if (this.fileFieldName) {
+				formData.append(this.fileFieldName, file);
 			}
-			if(this.urlFieldName){
-				formData.append(this.urlFieldName, url)
+			if (this.urlFieldName) {
+				formData.append(this.urlFieldName, url);
 			}
 			const response = await fetch(this.restApiUrl, {
-				method: 'POST',
+				method: "POST",
 				body: formData,
 				headers: this.headers,
 				signal: this.controller.signal
 			});
-			if ([200,201].includes(response.status)) {
+			if ([200, 201].includes(response.status)) {
 				// do something with the data?
 				const data = await response.json();
 			} else {
 				throw new Error(await response.text());
 			}
 		}
-		catch(e){
+		catch (e) {
 			throw new Error(e);
 		}
 	}