Skip to content

Instantly share code, notes, and snippets.

@ozozozd
Created May 13, 2017 22:23
Show Gist options
  • Save ozozozd/40905481b9cbb3b2326d759367ae34ab to your computer and use it in GitHub Desktop.
Save ozozozd/40905481b9cbb3b2326d759367ae34ab to your computer and use it in GitHub Desktop.
export default (request) => {
const kvstore = require('kvstore');
const xhr = require('xhr');
const http_options = {
"method": "POST",
"headers": {
"Authorization": "Bearer xvEdXQG3nyyXoFldhgvaoDE7Plipdz",
"Content-Type": "application/json"
},
"body": JSON.stringify({
"inputs": [
{
"data": {
"image": {
"url": "https://samples.clarifai.com/metro-north.jpg"
}
}
}
]
})
};
const url = "https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs";
console.log('request',request); // Log the request envelope passed
return xhr.fetch(url, http_options).then((x) => {
const body = JSON.parse(x.body);
console.log(body);
return request.ok();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment