Trying to use API but blocked by CORS policy #197
-
Hey! I am trying to use the API to fetch an avatar for my site, but the request is blocked by the CORS policy. Any suggestions on what I could do apart from set up a proxy server? I am using React. I have looked at the installation method but my application only uses yarn - would it still work with that as opposed to NPM? Edit: just tried with yarn and it worked! But still wondering about the CORS issue |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @MarianaK96 You don't have to fetch the images. Just put the URL in the function Avatar() {
return <img src="https://avatars.dicebear.com/api/identicon/mariana.svg" />;
}
export default Avatar; Alternatively, you can install the library. Of course, this also works with yarn. yarn install @dicebear/avatars @dicebear/avatars-identicon-sprites Here's how you can use the library in React: |
Beta Was this translation helpful? Give feedback.
Hi @MarianaK96
You don't have to fetch the images. Just put the URL in the
src
attribute of yourimg
element.Alternatively, you can install the library. Of course, this also works with yarn.
Here's how you can use the library in React:
#155