Snap not making network requests #2370
-
I am building a name-resolution snap and making a The API has no CORS policy and returns the header manifest "initialPermissions": {
"snap_dialog": {},
"endowment:network-access": {},
"endowment:name-lookup": {
"chains": [
"eip155:42220"
]
},
"endowment:rpc": {
"dapps": true,
"snaps": false
}
} snap code export const onNameLookup: OnNameLookupHandler = async ({
chainId,
domain,
address,
}) => {
if (domain && chainId === 'eip155:42220') {
if (domain) {
const domainSplit = domain.split(':');
const issuer = domainSplit[0];
const identifier = domainSplit[1];
if (
domainSplit.length > 1 &&
issuer &&
identifier &&
identifier.length >= 12 &&
isE164Number(identifier)
) {
const response = await fetch(
`https://minipay-lookup-service-react-app.vercel.app/api/socialconnect/lookup`,
{
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ handle: identifier }),
method: 'GET',
},
);
const data = await response.json();
const { accounts } = data;
console.log(accounts);
return {
resolvedAddresses: [
{
resolvedAddress: accounts[0],
protocol: 'MiniPay SocialConnect',
},
],
};
} else {
return null;
}
}
if (address) {
// Domain lookup is not possible in SocialConnect
return null;
}
}
return null;
}; |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I don't think you can pass any parameters to |
Beta Was this translation helpful? Give feedback.
-
The way to pass parameters to the URL would be as URL parameters, like |
Beta Was this translation helpful? Give feedback.
-
ah... I will give the query params a try, thank you for having a look! AFK right now. |
Beta Was this translation helpful? Give feedback.
I don't think you can pass any parameters to
fetch()
. Just the URL. Can you try that and log the response to the console?