I am new to JavaScript and Node.js. The problem is that I don't know how to use artifactoryAPI in NPM react.
It is easy to run curl in Linux terminal to upload/download like this:
curl -u myUser:myP455w0rd! -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt
But I want to use this API in my localhost there is a button to submit. According to "https://npm.runkit.com/artifactory-api" it will be used:
import ArtifactoryAPI from 'artifactory-api/lib/ArtifactoryAPI';
.......
handleSubmit(){
var artifactory = new ArtifactoryAPI('http://localhost:8080',
Buffer.from("user:password:","utf8).toString("base64));
artifactory.uploadFile('libs-release-local', '/my/jar/1.0/jar-1.0.jar', '/Users/user/artifacts/jar-1.0.jar').then(function (uploadInfo) {
console.log('UPLOAD INFO IS: ' + JSON.stringify(uploadInfo));
}).fail(function (err) {
console.log('ERROR: ' + err);
});
}
.....
render(){
return (
......
<button type="submit">Submit</button>
....
)
}
It doesn't work. As I mentioned that I am very new to NPM.