google-cloud-tasks
Version:
Nodejs package to push tasks to Google Cloud Tasks (beta). Include pushing batches.
23 lines (20 loc) • 780 B
JavaScript
/**
* Copyright (c) 2018, Neap Pty Ltd.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const fetch = require('node-fetch')
const postData = (url, headers={}, body) => Promise.resolve(null).then(() => {
return fetch(url, { method: 'POST', headers, body })
.then(res => res.json().catch(() => res.text().catch(() => res)).then(data => ({ status: res.status, data })))
})
const getData = (url, headers={}) => Promise.resolve(null).then(() => {
return fetch(url, { method: 'GET', headers })
.then(res => res.json().catch(() => res.text().catch(() => res)).then(data => ({ status: res.status, data })))
})
module.exports = {
post: postData,
'get': getData
}