upstash / qstash-js

Message queue for serverless
https://docs.upstash.com/qstash
MIT License
133 stars 11 forks source link

not scheduling msg to the provided URL V1 publish endpoints #66

Closed Rishavraaj closed 8 months ago

Rishavraaj commented 8 months ago

I am scheduling a job using v1/publish endpoint but its not scheduling to the endpoint which i provided in my QSTASH_URL

here is my code

const baseUrl = "https://qstash.upstash.io/v1/publish/";

const url = `${baseUrl}${process.env.NEXT_PUBLIC_QSTASH_URL}`;
const token = process.env.NEXT_PUBLIC_QSTASH_TOKEN;

export const myscheduler = async (
  time: string,
  id: string
) => {
  const times = dayjs(time).local().unix();

  const cronTimeUTC = dayjs.unix(times).utc().format("mm HH * * *");

  try {
    const response = await axios.post(
      url,
      { id },
      {
        headers: {
          Authorization: `Bearer ${token}`,
          "Upstash-Cron": cronTimeUTC,
        },
      }
    );
    return response.data.scheduleId;
  } catch (error) {
    console.log("error", error);
  }
};
fahreddinozcan commented 8 months ago

Hi @Rishavraaj,

I was able to create a schedule with the code snippet you provided. Could you please provide more details about the error you're getting? And you could maybe provide some info about the format you pass time and url to the function?

Rishavraaj commented 8 months ago

@fahreddinozcan i resolved the issue thanks for the help , i am closing this issue