Impeccable
This commit is contained in:
23
meta-fix.js
Normal file
23
meta-fix.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { config } from 'dotenv';
|
||||
config();
|
||||
|
||||
const TOKEN = process.env.META_ACCESS_TOKEN;
|
||||
const BASE = 'https://graph.facebook.com/v21.0';
|
||||
|
||||
async function api(path, method = 'GET', body) {
|
||||
const url = new URL(`${BASE}/${path}`);
|
||||
url.searchParams.set('access_token', TOKEN);
|
||||
const res = await fetch(url.toString(), {
|
||||
method,
|
||||
headers: body ? { 'Content-Type': 'application/json' } : undefined,
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(JSON.stringify(data));
|
||||
return data;
|
||||
}
|
||||
|
||||
console.log('Pausing orphaned ad sets...');
|
||||
await api('6968509692127', 'POST', { status: 'PAUSED' });
|
||||
await api('6958800756527', 'POST', { status: 'PAUSED' });
|
||||
console.log('Done: Paused 2 orphaned ad sets (New Sales Ad Set, New Sales ad set)');
|
||||
Reference in New Issue
Block a user