Implementation for the Data Deletion Callback in JavaScript for Node with Expressjs.
The most stupid pitfall for this callback is that the response has to look like this:
{ url: '<url>', confirmation_code: '<code>' }
This and other more reasonable variations are invalid:
{ "url": "<url>", "confirmation_code": "<code>" }
This means you cannot use JSON.stringify
or Response.json(object)
, but this glorious snippet:
res.type('json')
res.send(`{ url: '${url}', confirmation_code: '${confirmationCode}' }`)
Another pitfall is that Facebook's signature always has a =
appended (see line 43 in parseSignedRequest.mjs).
I left those out intentionally because the gist is just supposed to show how the data deletion request works.
If you implement this yourself, you can just leave out the calls to the log functions.
If you want to know how to get the full URI of a request, check out this Stackoverflow post.
ResponseError is simply a plain JavaScript error with a status property, and causes Node to respond with the corresponding HTTP error code.