Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oshliaer/fetch
The Google Apps Script FetchApp wrapper
https://github.com/oshliaer/fetch
Last synced: 4 days ago
JSON representation
The Google Apps Script FetchApp wrapper
- Host: GitHub
- URL: https://github.com/oshliaer/fetch
- Owner: oshliaer
- License: mit
- Created: 2018-03-29T01:16:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-03-29T01:28:21.000Z (over 6 years ago)
- Last Synced: 2024-04-09T21:12:24.801Z (7 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fetch
The Google Apps Script FetchApp wrapperShort your code
## Default `get` with Authorization
```js
function getBlog(){
var response = Fetch.get("https://www.googleapis.com/blogger/v3/blogs/blogId");
Logger.log(response.getContentText())
}
```## Default `post` with Authorization, contentType and stringify payloads
```js
function createPost(){
var content = DocumentApp.openById("ID").getBody().getText();var options = {
payload: {
"kind": "blogger#post",
"blog": {
"id": "blogId"
},
"title": "A new post",
"content": content
},
}
var response = Fetch.post("https://www.googleapis.com/blogger/v3/blogs/blogId/posts", options);
Logger.log(response.getContentText())
}
```## Default `put` with Authorization, contentType and stringify payloads
```js
function updatePost(){
var docExport = Drive.Files.get("ID").exportLinks["text/html"];
var content = Fetch.get(docExport).getContentText();
var options = {
payload: {
"kind": "blogger#post",
"id": "postId",
"blog": {
"id": "blogId"
},
"selfLink": "https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId",
"title": "An updated post",
"content": content
},
}
var response = Fetch.put("https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId", options);
Logger.log(response.getContentText())
}
```