Created
June 3, 2020 08:02
-
-
Save peterdresslar/a86de5c3034e08668b578bf96d6d259b to your computer and use it in GitHub Desktop.
Kreezalid API Nodejs Axios Example
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
const dotenv = require("dotenv"); | |
dotenv.config(); | |
const apiUser = process.env["KREEZALID_USER_ID"]; | |
const apiSecret = process.env["KREEZALID_USER_SECRET"]; | |
const axios = require("axios"); | |
var options = { | |
order_type_url_token: "8drhwt0y3f", | |
category_id: 21842, | |
user_id: 35682, | |
title: "Test API Up 6", | |
description: "Elite motorcycle used in MotoGP.", | |
price: 1500, | |
is_online: false, //not working | |
on_homepage: false, //not working | |
location: "France", | |
attributes: { | |
type_of_story: 181863, | |
beats: [ | |
//does work | |
178614, | |
181869, | |
178611, | |
], | |
name_of_publication: "Zenith", | |
publication_date_of_article: 1571405070, | |
available_for_international_licensing: 1580304270, | |
original_language: 178650, | |
licensable_languages: [ | |
179998, | |
179999, | |
180000 | |
], | |
article_length_in_words: 1879, | |
article_length: 180211, | |
article_length_in_characters_no_spaces: 11285, | |
guaranteed_exclusivity: 189422, | |
republication_needs_to_mention_original_publication: 189429, | |
can_the_publication_sell_the_rights_for_this_article: 184731, | |
images_new: 185704, | |
images: 185702, | |
story_id: "cTESTFOO0001BARBAZ", | |
}, | |
}; | |
var postArticle = async (attrs) => { | |
console.log("calling Kreezalid "); | |
try { | |
let response = await axios({ | |
method: "post", | |
url: "https://www.thestorymarket.co/api/v1/listings", | |
auth: { | |
username: apiUser, | |
password: apiSecret, | |
}, | |
headers: { | |
"content-type": "application/json", | |
}, | |
timeout: 5000, | |
data: options, | |
}); | |
if (!response) { | |
console.log("no response from api"); | |
} else { | |
console.log(response.data); | |
} | |
} catch (error) { | |
console.error(error); | |
} | |
}; | |
const resp = postArticle(options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment