React Native
React Native
Delete a Task List
See more Google Tasks Examples
Demonstrates how to delete a Google task list.Chilkat React Native Downloads
import { FileAccess, Http, HttpResponse } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Get the previously obtained access token.
// See Get Google Tasks Access Token.
const fac = new FileAccess();
let accessToken: string;
try {
accessToken = fac.readEntireTextFile('qa_data/tokens/googleTasks.txt', 'utf-8');
} catch {
console.log(fac.lastErrorText);
return;
}
const http = new Http();
http.authToken = accessToken;
// Delete the task list with this ID: MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6OTk5Njk3NjkxNzg4Nzg2NDow
http.setUrlVar('taskListId', 'MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6OTk5Njk3NjkxNzg4Nzg2NDow');
const resp = new HttpResponse();
try {
await http.httpNoBodyAsync('DELETE', 'https://www.googleapis.com/tasks/v1/users/@me/lists/{$taskListId}', resp);
} catch {
console.log(http.lastErrorText);
return;
}
// Show the response body. (empty for success)
console.log(resp.bodyStr);
// Examine the response status code. (204 = success)
console.log(`response status code: ${resp.statusCode}`);
}