lbry.tech/app/helpers/publish-meme.js

35 lines
614 B
JavaScript
Raw Normal View History

2018-08-18 00:22:19 +02:00
"use strict";
2018-11-30 21:46:22 +01:00
// I M P O R T
2018-08-18 00:22:19 +02:00
2018-11-30 21:46:22 +01:00
import got from "got";
// U T I L
2018-11-30 21:46:22 +01:00
const queryUrl = process.env.NODE_ENV === "development" ?
"http://localhost:5200/publish" :
`https://${process.env.DAEMON_URL}/publish`;
2018-08-18 00:22:19 +02:00
// E X P O R T
2018-11-30 21:46:22 +01:00
export default async(publishMetadata) => {
const options = {
body: {
authorization: process.env.LBRY_DAEMON_ACCESS_TOKEN,
metadata: publishMetadata
},
2018-11-30 21:46:22 +01:00
json: true
};
try {
2018-11-30 21:46:22 +01:00
const response = await got.put(queryUrl, options);
return response.body; // eslint-disable-line padding-line-between-statements
2019-02-05 00:42:52 +01:00
} catch(error) {
return error;
}
};