Last active
February 23, 2023 04:36
-
-
Save classmember/72ab335223722623af9ed5346e5ed6eb to your computer and use it in GitHub Desktop.
OpenAI_client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prompt: | |
// Write a frontend JavaScript function to upload a .zip file from a chrome extension in a browser to a node backend using express. The code must publish to a POST endpoint over HTTPS. | |
// Response: | |
// Note: This code assumes the use of jQuery for the AJAX request | |
function uploadZipFile(file) { | |
let formData = new FormData(); | |
formData.append('file', file); | |
$.ajax({ | |
type: 'POST', | |
url: 'https://mybackend.com/upload', | |
data: formData, | |
contentType: false, | |
processData: false, | |
success: (data) => { | |
console.log(`Upload successful!`); | |
}, | |
error: (err) => { | |
console.log(`Upload failed: ${err}`); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment